LeetCode 3Sum Solution Explained - Java

Поділитися
Вставка
  • Опубліковано 11 жов 2024
  • The Best Place To Learn Anything Coding Related - bit.ly/3MFZLIZ
    Join my free exclusive community built to empower programmers! - www.skool.com/...
    Preparing For Your Coding Interviews? Use These Resources
    --------------------
    (My Course) Data Structures & Algorithms for Coding Interviews - thedailybyte.d...
    AlgoCademy - algocademy.com...
    Daily Coding Interview Questions - bit.ly/3xw1Sqz
    10% Off Of The Best Web Hosting! - hostinger.com/...
    Follow Me on X/Twitter - x.com/nickwhit...
    Follow My Instagram - / nickwwhite
    Other Social Media
    ----------------------------------------------
    Discord - / discord
    Twitch - / nickwhitettv
    TikTok - / nickwhitetiktok
    LinkedIn - / nicholas-w-white
    Show Support
    ------------------------------------------------------------------------------
    Patreon - / nick_white
    PayPal - paypal.me/nick....
    Become A Member - / @nickwhite
    #coding #programming #softwareengineering

КОМЕНТАРІ • 201

  • @jonathanl3068
    @jonathanl3068 3 роки тому +204

    I love how his submit history is all red

  • @tim37021
    @tim37021 3 роки тому +7

    if your are using c++
    for(...;i

    • @vishnusreddy
      @vishnusreddy 3 роки тому +1

      Can you please explain why this happens? For other programs, I can use for(int = 0; i>nums.size();i++){} and it works.

  • @Icix1
    @Icix1 4 роки тому +35

    You can use a Set (HashSet) instead of a List to reduce the amount of edge cases you need to think about or amount of checks you need to do. A fair amount of your code just checking whether to skip duplicates and other edge cases, and these will be hard to remember in an interview setting. One thing I've noticed is if the result requires deduped anything, it's just easier to throw things at the Set and let the data structure do the work for you, then convert to a List on return. Otherwise, great explanation, good work!

    • @mason430
      @mason430 4 роки тому +5

      You are a freaking genius. I'd been at this for hours trying to get this duplicate thing down and your comment ended my misery in three minutes. Thank you kind sir.

    • @tommyypoon
      @tommyypoon 4 роки тому +1

      How would a hashset allow you to have the case [-1, -1, 2] like in the example?

    • @mason430
      @mason430 4 роки тому +4

      @@tommyypoon Store [-1, -1, 2] as a key and then return all the keys in array form at the end. The hash prevents you from having duplicate [-1, -1, 2] in your return set as the second one will simply overwrite the first in the hash.

    • @tommyypoon
      @tommyypoon 4 роки тому +2

      @@mason430 ahh i see, so you have a hashset which contains a list of integers as the keys?

    • @Icix1
      @Icix1 4 роки тому +4

      @@tommyypoon One of the big tricks with this problem is figuring out what to do with duplicate answers. You can definitely work around some of these cases by taking advantage of the sorted properties of the array. But these checks can get complicated and might be error prone. So the trick is to use a data structure that does it all for you. In this case, the list of integers is a key, and any writes to the set either adds a new key or update an existing one.

  • @leomonz
    @leomonz 4 роки тому +16

    nums[i] != nums[i-1] but in teh example they have two -1s, if you sort it then it is i and i-1

  • @OctTEN_1010
    @OctTEN_1010 3 роки тому +7

    am so glad that he came back and run the code!!!

  • @akshayrana9351
    @akshayrana9351 4 роки тому +3

    Sorting: O(nlogn)
    Two loops: O(n^2)
    Duplicate check: O(n^2)
    Total: O(n^2) + O(nlogn)

    • @rutujtarte1991
      @rutujtarte1991 4 роки тому +1

      Ikr but is this an optimal soln ?
      It kinda looks like it cause brute Force soln would yield in O(n^3)

    • @abhipsamohapatra852
      @abhipsamohapatra852 4 роки тому

      why didnt he use hashmap like in case of two sum

    • @jaredtewodros
      @jaredtewodros 4 роки тому

      @@abhipsamohapatra852 since the brute force approach for this problem is n^3, you can afford to do two sum with sorting and the two pointers because that will give you an overall runtime of n^2. If you were to use the hashmap approach, you would have the same running time but need to allocate additional space

    • @sanyasingh9625
      @sanyasingh9625 4 роки тому

      @@jaredtewodros I am using two for loops and still getting time out error. It should be O(n^2) right?
      ans = []
      for i in range(len(nums)):
      for j in range(i+1, len(nums)):
      k = -(nums[i] + nums[j])
      if k in nums[j+1:]:
      temp_arr = [nums[i], nums[j], k]
      temp_arr.sort()
      if temp_arr not in ans:
      ans.append(temp_arr)
      return ans

  • @anvitabansal5329
    @anvitabansal5329 4 роки тому +14

    Sir how can it be solved using hashmap as in two sum problem where we can consider the target in two sum to be negative of nums[i] ?

    • @adhishmalviya2408
      @adhishmalviya2408 4 роки тому +6

      Yes, you can use the hashmap also to solve two sum,
      and when we are doing that
      we need not to sort them,
      but in 3sum , sorting is necessary
      that's why instead of using hashmap we can use two pointer technique
      which will save space
      anyways you can also solve 3sum with hashmap

    • @MahirHasancse21
      @MahirHasancse21 4 роки тому

      @@adhishmalviya2408 Can the time complexity is N(logn) because of hashmap?

    • @Vidur11
      @Vidur11 4 роки тому +1

      @@MahirHasancse21 Time complexity won't change if we use a hashmap in this case since the tc of a hashmap lookup is amortized O(1), from my understanding.

    • @MahirHasancse21
      @MahirHasancse21 4 роки тому

      @@Vidur11 Thank you very much

    • @ranajitmukherjee9789
      @ranajitmukherjee9789 4 роки тому +2

      @@adhishmalviya2408 hey can u please explain why sorting is necessary in 3 sum?

  • @honeyjha7217
    @honeyjha7217 4 роки тому +14

    This method doesn't gives the triplet [-1,-1,2] because it skipped -1.

    • @jenny3416
      @jenny3416 4 роки тому

      yeah I was wondering about that..

    • @yulinglang
      @yulinglang 4 роки тому +5

      Actually it works. when num[i] is the first -1, it gets -1 and 2 as low and high. When goes to the next iteration of for loop, It skips the second -1 as num[i], as it supposed to avoid duplicate.

    • @AniketSomwanshi-ll7mz
      @AniketSomwanshi-ll7mz 3 роки тому

      ​@@yulinglang what if the correct triplet is -1,-1,-1 ? I am actually confused over why we'd just discard duplicate in this case!!

    • @yulinglang
      @yulinglang 3 роки тому +2

      @@AniketSomwanshi-ll7mz Duplicate meaning : if you have -1 as the leading number (num[i]) of the triplet , then don't use it as leading number again if num[i+1]= -1 too. otherwise, you'll have duplicate. Duplicate does not mean avoid repeating numbers in the triplet itself, so you will not exclude in your result. If you are still confused, try stepping into his code with real input. For instance, WHEN array is {-1, -1, -1, -1}, and target sum is -3, THEN result should contain only 1 triplet , instead of 2.

    • @AniketSomwanshi-ll7mz
      @AniketSomwanshi-ll7mz 3 роки тому

      @@yulinglang gotcha!! Thanks a lot!

  • @praveen3791
    @praveen3791 2 роки тому +4

    Do we have any other approach where we can reduce the time complexity?

  • @maithreyiprabhu8605
    @maithreyiprabhu8605 4 роки тому +6

    Can you please add the time complexity and space complexity explanation for each problem you solve?

  • @hemaladani4510
    @hemaladani4510 4 роки тому +2

    Took me a while to understand.
    [i] != [i-1] because if same num[i] is found then results would also be the same. We want to avoid same results.
    Same for
    while(low

    • @hemaladani4510
      @hemaladani4510 4 роки тому

      Over all love your videos than others. For some reason, I can't look at solutions from other youtubers. Thank you!

    • @aileenqu4244
      @aileenqu4244 2 роки тому

      Thank you so much! I've been stuck in this line for a while. Thanks to your explanation now I understand. :D

  • @shreyavhadadi4887
    @shreyavhadadi4887 4 роки тому +2

    What if the array contains only [-2,1,1] how does the code check for the duplicate?

  • @leezhenjian7451
    @leezhenjian7451 9 місяців тому

    tough question for me , i couldn't get the solution for leetcode so i came here. helps alot, thanks man!

  • @vasujhawar.6987
    @vasujhawar.6987 Рік тому

    How the hell, you made it look so easy.... man I am subscribing to your course.

  • @uberandrew123456
    @uberandrew123456 2 роки тому +2

    this is a good explanation of the solution, but a poor representation on how to reason through the problem and come to the solution that was explained. Giving the fish but not teaching how to catch it typa-thing

  • @GuruBala
    @GuruBala 2 роки тому +3

    Your simple explanation just made it easy... but its not! You're awesome!

  • @keremkeskin8477
    @keremkeskin8477 3 роки тому +2

    Thanks for solution. I have a question. Like this question, in some question, I have an error called Time Limit Exceeded. Actually code is true, but code can be crowded. What could you recommend for this issue?

    • @BrasilEmFatos
      @BrasilEmFatos 3 роки тому

      This is happening because some loop is going infinite and never stops...

  • @yadneshkhode3091
    @yadneshkhode3091 4 роки тому +4

    sir thank you so much for people like me who can't afford courses you are great help sir did you upload all the problems you have ever solved on youtube or there are some which you haven't uploaded here

  • @galwije
    @galwije 2 роки тому +1

    All these people remember the algorithm and thats it. Dont sweat it guys just memorize

  • @The2Coolest2
    @The2Coolest2 2 роки тому

    I get a random runtime error at a test case during submission. "[-7,-4,-6,6,4,-6,-9,-10,-7,5,3,-1,-5,8,-1,-2,-8,-1,5,-3,-5,4,2,-5,-4,4,7]" is the last input. "Heap buffer overflow". Not sure where I'm going out of bounds in this case, just getting the registers in the error message.
    Edit: Followed the call stack plugging it into visual studio, found the problem. Ran out of room for my answer vector. Updated the program to resize more appropriately. :) Unfortunately run time doesn't seem great. Not sure if the vector resizing is slowing it down.

  • @andrewtran2895
    @andrewtran2895 4 роки тому +5

    doesn't this solution skip over [-1, -1, 2], through your solution, if you sort it first you get [-1, 0, 1] then you skip the next -1 you see and never get the other solution, right?

    • @prathamj2215
      @prathamj2215 4 роки тому

      exactly my question> did you get the solution?

    • @tommyypoon
      @tommyypoon 4 роки тому

      Andrew Tran you skip -1 in the inner while (low < high) loop, once you break out of that loop, your next nums[i] becomes -1

    • @leomonz
      @leomonz 4 роки тому

      I also dont know how that works. Even Tommy Poon explained it and I am still confused

    • @tommyypoon
      @tommyypoon 4 роки тому +2

      @@leomonz I rewatched it and realized you actually find [-1,-1,2] first before you find [-1,0,1]
      Sort the array
      [-4, -1, -1, 0, 1, 2]
      i = 0
      low = index 1
      high = index 5
      sum = 0 - (-4) = 4
      // go through while low < high loop and didn’t find a sum = 4
      i = 1
      low = index 2
      high = index 5
      sum = 0 - (-1) = 1
      // while low < high
      -1 + 2 == 1 which equals sum, if condition satisfied
      output.add([-1, -1, 2])
      is index 2 == index 3, no
      is index 5 == index 4, no
      low = index 3
      high = index 4
      // still inside while (low < high) loop
      0 + 1 == 1 which equals sum, if condition satisfied
      output.add([-1, 0, 1]);

  • @sowmyasguru
    @sowmyasguru 4 роки тому +2

    This program does not pass for [-1,0,1,2,-1,-4]. The Expected output is
    [[-1,-1,2],[-1,0,1]]

    • @AjayKumar-zm9db
      @AjayKumar-zm9db 4 роки тому

      Yeah, he is skipping -1 value (in the i loop) for this particular test case.

  • @fortressonahill5860
    @fortressonahill5860 2 роки тому

    that ending was perfect lmao

  • @sanyuktakate4099
    @sanyuktakate4099 5 років тому +2

    This does not remove the duplicates.

  • @toekneema
    @toekneema 5 років тому +4

    great video, could you explain why you used a LinkedList as opposed to the nested ArrayList?

  • @shastriswaroop
    @shastriswaroop 4 роки тому

    I am getting timeout for the below code. Looks to me I am doing similar to what is shown in video. My solution is to use three pointer and remove duplicate using set. How can I optimize it further ? Any idea/hint?
    public List threeSum(int[] nums) {
    Set set = new HashSet();
    if (nums == null) {
    return new ArrayList(set);
    }
    int arrLen = nums.length;
    if (arrLen < 3) {
    return new ArrayList(set);
    }
    Arrays.sort(nums);
    int i = 0;
    int j = 1;
    int k = arrLen - 1;
    int sum = 0;
    while (i < arrLen && j < arrLen && k < arrLen) {
    sum = nums[i] + nums[j] + nums[k];
    if (sum == 0) {
    set.add(Arrays.asList(nums[i], nums[j], nums[k]));
    }
    if (k == arrLen - 1 && j == arrLen - 2) {
    i++;
    j = i + 1;
    if (j == k) {
    break;
    }
    continue;
    }
    if (k > j) {
    k--;
    }
    while (k == j) {
    k = arrLen - 1;
    j++;
    }
    }
    return new ArrayList(set);
    }

  • @johnlee416
    @johnlee416 5 років тому +1

    I don't understand how this gets all possible solutions. How is it necessarily true that nums[low] + nums[high] would equal the sum. What if it was nums[low] + nums[high-1] = sum. We would never get that value then because you increment low and high at the same time.

    • @anshulabhinav13
      @anshulabhinav13 4 роки тому

      He first sorted the array, then going from start and going from end. If sum is > then decrement end counter else increment start counter. The key here is that he sorted the array first.

  • @CandyMoney1000
    @CandyMoney1000 3 роки тому +7

    Damn dude you make it look so easy. Thanks for all the help!

    • @StefanDumitru1
      @StefanDumitru1 3 роки тому +7

      irl the way this guy presents the direct answer and explanation is not how your train of taught would go.

  • @ruslansamatov2819
    @ruslansamatov2819 Рік тому +2

    not a 3some i dream about , but super useful)

  • @SHSelect
    @SHSelect 2 роки тому

    Thank you Nick. but why used LinkedList instead of ArrayList here?

  • @vikrantbhati6088
    @vikrantbhati6088 3 роки тому +1

    Will the solution work for array given 0,0,0,0,0,0 and sum required is 0 ? I mean there should be one solution as 0,0,0 right ?

    • @lostgoat
      @lostgoat 3 роки тому

      Should return []

  • @aylmao1045
    @aylmao1045 4 роки тому +5

    Can anyone explain the skip duplicate part?

    • @nitikaraj4648
      @nitikaraj4648 3 роки тому

      basically the target would be same in case of duplicates & this way you can reduce a redundant iteration

  • @thepantelemon
    @thepantelemon 3 роки тому +1

    For some reason this code doesn't work on leetcode, I hope I haven't made any mistakes. But if you put low and high increments before whiles and comment out the second while(duplicate search) the code passes tests.

    • @vishalsepaia3448
      @vishalsepaia3448 3 роки тому

      True True,
      this is what he wrote(just for reference, if required)
      class Solution {
      public List threeSum(int[] nums) {
      List l1 = new ArrayList();
      Arrays.sort(nums);
      if(nums.length==0 || nums.length==1 || nums ==null) return l1;
      for(int i=0; i< nums.length-2; i++){
      if(i==0 || (i> 0 && nums[i]!=nums[i-1])){
      int low = i+1, high = nums.length-1, sum = 0-nums[i];
      while(low

  • @neelkanthsharma407
    @neelkanthsharma407 2 роки тому

    TwoSum array doesn't require array to be sorted...Why did you sort it out?

  • @normanteqwon1763
    @normanteqwon1763 2 роки тому

    Algorithm so much simpler than other peoples like it’s ridiculous how complicated they can make this problem lol

  • @abhishekkumargupta3043
    @abhishekkumargupta3043 4 роки тому +2

    To anyone looking for C++ solution:
    class Solution {
    public:
    vector threeSum(vector& nums) {
    vector ans;
    if(nums.size()

  • @danielmcgee2447
    @danielmcgee2447 3 роки тому

    why do we need the i==0 in if (i == 0 || nums[i - 1] != nums[i])

  • @darkhorse621
    @darkhorse621 4 роки тому +2

    clear explanation about the usage of two pointers to solve complex problem. Keep up the good work !
    god bless !!!

  • @antasjain
    @antasjain 4 роки тому

    all cases don't run. by this logic if array have 0,0,0 as inputs, it returns empty list

  • @leo-kwo
    @leo-kwo 2 роки тому

    Great video and I have always found the name of this question…interesting

  • @taran7649
    @taran7649 2 роки тому

    In the example [-1,-1,2] isn't it duplicate

  • @nadaz7333
    @nadaz7333 4 роки тому

    why didn't you use the hash table method for 2 sum

  • @jackyyang9026
    @jackyyang9026 3 роки тому

    in the case we found our answer and skip all duplicated number why move both low and high?

    • @jackyyang9026
      @jackyyang9026 3 роки тому

      i've figured it out! sry for stupid question lol.

  • @anantprakashsingh8777
    @anantprakashsingh8777 2 роки тому

    Great explanation, you don't sound like you want to be alive, but great explanation!

  • @bethlehemteshome3660
    @bethlehemteshome3660 4 роки тому +10

    Bless your soul

  • @janhavisanjaybhosle9933
    @janhavisanjaybhosle9933 2 роки тому

    What is the time and space complexity for this?

  • @rrsonia10
    @rrsonia10 4 роки тому

    Thanks for the clear explanation. What is the time complexity of this?

  • @Keyakina
    @Keyakina 4 роки тому +2

    This has to be able to do without sorting right?

    • @vikramreddy7586
      @vikramreddy7586 4 роки тому

      Keya Kinan not necessarily. If you don’t sort then tracking duplicates will be very tricky

    • @Vidur11
      @Vidur11 4 роки тому

      @@vikramreddy7586 Technically, the need to sort arises in this question due to the two pointer method he uses for two sum, which you cannot use without a sorted array. An added advantage to sorting is that it takes care of duplicates.

    • @nourgaser6838
      @nourgaser6838 2 роки тому

      @@vikramreddy7586 late to the party but the duplicates can be skipped with a hashset to skip the already seen elements.

  • @satyanveshvanapalli9905
    @satyanveshvanapalli9905 3 роки тому

    I have a question here why we used linked list instead of ArrayList

  • @taran7649
    @taran7649 2 роки тому

    line 15 16 17 18 why do you write twice low++ high ++

  • @nebiyoupaulos9800
    @nebiyoupaulos9800 3 роки тому +4

    there's no way in hell you solved this in real-time.

  • @Richard-ok5un
    @Richard-ok5un 4 роки тому +1

    Very clear and great explanation

  • @himanshukhanna2589
    @himanshukhanna2589 2 роки тому

    Threesum is similar to twosum -
    Nick White

  • @sujandvss2612
    @sujandvss2612 3 роки тому

    This code doesn't work for [-1,-1,0,1]

  • @warrenwong4518
    @warrenwong4518 3 роки тому

    This does not work for [0,0,0] as an input

  • @fakeasfluff6842
    @fakeasfluff6842 2 роки тому +1

    God, this is so confusing still

  • @andreas6508
    @andreas6508 4 роки тому +1

    it's still O(n^2) right

    • @codewithjc4617
      @codewithjc4617 3 роки тому

      Yes, but it's a decent runtime for this problem

  • @arghyamitra3281
    @arghyamitra3281 3 роки тому +1

    [0,0,0] it won't work

  • @taran7649
    @taran7649 2 роки тому

    I didnt understand the sorted part like why do we sort it

  • @srinadhp
    @srinadhp 3 роки тому +2

    Thank you! You made it so simple with your explanation.

  • @milanpatel6240
    @milanpatel6240 3 роки тому +2

    Super easy and nice explanation. Thanks Nick

  • @augustoalmeida2586
    @augustoalmeida2586 3 роки тому

    Does anyone knows which companies ask for this question?

  • @ankitkohli727
    @ankitkohli727 2 роки тому

    Can anyone explain why a linked list was used?

  • @adamajs3836
    @adamajs3836 2 роки тому

    Only devs can get away with saying 3some in workplace

  • @partheshsoni6421
    @partheshsoni6421 4 роки тому +1

    Nicely explained! Well done.

  • @AmanSingh-ji9dm
    @AmanSingh-ji9dm 3 роки тому

    Why did he handle duplicates twice?

  • @viralindian8326
    @viralindian8326 4 роки тому +3

    Thanks Nick by heart 💓♥️

  • @debagniksen7809
    @debagniksen7809 2 місяці тому

    The real world 3 some is not even a problem.

  • @abiramid4636
    @abiramid4636 3 роки тому +1

    can somebody explain the time complexity for this problem?

    • @edgarsanmartinjr.4278
      @edgarsanmartinjr.4278 3 роки тому

      We are looping through the entirety of the array - 2 which is a linear operation. In each iteration we are performing a two sum, two pointer algorithm which is also a linear operation. All of this is dependent on the size of the inputted array n. Thus, time complexity is O(n^2)

    • @edgarsanmartinjr.4278
      @edgarsanmartinjr.4278 3 роки тому

      Forgot we sorted this array as well in the beginning of the function so O(nlogn + n^2) to be exact, but we drop the lowest multiplier so it would still be O(n^2)

  • @akritbehera7751
    @akritbehera7751 2 роки тому

    Why i>0? in line 7?

  • @SnortsOfHappiness
    @SnortsOfHappiness 3 роки тому

    MY BOI AT IT AGAIN

  • @davidj2597
    @davidj2597 5 років тому +3

    Keep it up. I love your videos

  • @juanguang2076
    @juanguang2076 4 роки тому

    ok, so he basically make the three numbers to be unique.

  • @elvinjafarli6257
    @elvinjafarli6257 5 років тому +1

    Clear explanation! Thank you!

  • @samsundar6561
    @samsundar6561 2 роки тому

    Great Explanation,Thanks!

  • @abhimalyachowdhury7835
    @abhimalyachowdhury7835 2 роки тому

    I got TLE following this approach in python..Don't know why

  • @vikassharma4780
    @vikassharma4780 4 роки тому

    i think your linkden url is broken here.

  • @krishnabhagat2716
    @krishnabhagat2716 3 роки тому

    sir why for "nums.length-2" their in for loop i.

    • @stanley6182000
      @stanley6182000 3 роки тому

      Because you would need at least 2 index space for the low and high pointer

    • @krishnabhagat2716
      @krishnabhagat2716 3 роки тому

      @@stanley6182000 Understood Thanks for your reply

  • @hashiramasenju293
    @hashiramasenju293 3 роки тому

    the only 3sum i can afford

  • @siddhishah__cse5796
    @siddhishah__cse5796 3 роки тому +1

    can you please tell me the exact real time application of 3sum problem ..

  • @AnilKumar-un1zo
    @AnilKumar-un1zo 3 роки тому

    Great solution brahh.

  • @bsuperbrain
    @bsuperbrain 4 роки тому

    but you sorted the array, was it allowed?

    • @willinton06
      @willinton06 4 роки тому

      bsuperbrain as long as it isn’t prohibited it is allowed

    • @sk8sbest
      @sk8sbest 4 роки тому

      @@willinton06 lol

  • @brandonnoll5527
    @brandonnoll5527 3 роки тому

    Great solution!

  • @SailaMaham
    @SailaMaham 4 роки тому +4

    I think I'm starting to have a crush on you haha

  • @vulturebeast
    @vulturebeast 5 років тому +3

    you're awesome ..Subscribed 👍 please upload more hard ones thanks

    • @NickWhite
      @NickWhite  5 років тому +2

      thank you bro I’ll be uploading a lot more soon

    • @ThabiraGamingShorts
      @ThabiraGamingShorts 4 роки тому

      @@NickWhite you are great bro.please upload hard one more as well as medium also

  • @georgezuo6462
    @georgezuo6462 4 роки тому +1

    This is awesome, thank you!

  • @tyz5313
    @tyz5313 5 років тому +2

    nice solution!

  • @webknowledge9989
    @webknowledge9989 2 роки тому

    I don't get it

  • @aumrudhlalkumartj1948
    @aumrudhlalkumartj1948 2 роки тому

    Thanks

  • @montuedge
    @montuedge 3 роки тому

    Was waiting for hashmap...never came

  • @shobhitranjan3957
    @shobhitranjan3957 4 роки тому +1

    Good Work!

  • @souvikghosh5668
    @souvikghosh5668 4 роки тому

    Anyone getting output as [[1,-1,2],[1,0,1]] for input
    [-1,0,1,2,-1,-4]?

    • @sowmyasguru
      @sowmyasguru 4 роки тому +2

      No. This program is flawed

  • @shashikantkumar5095
    @shashikantkumar5095 4 роки тому +1

    ur great sir!!

  • @rhythmjain5331
    @rhythmjain5331 4 роки тому

    good explanation

  • @divyanshuchaudhari5416
    @divyanshuchaudhari5416 4 роки тому

    Good solution but not time efficient..faster than only 40% of the submissions.

  • @shubhamladha5426
    @shubhamladha5426 4 роки тому

    bro you are awesome

  • @曹小虎-k4n
    @曹小虎-k4n 4 роки тому

    very excellent, thanks

  • @HIOLLJ
    @HIOLLJ 4 роки тому

    Succinctly explained Nick :)

  • @papaz.z853
    @papaz.z853 2 роки тому

    Like your video. Thanks

  • @CleanCoder
    @CleanCoder 3 роки тому

    Awesome !