LeetCode 3Sum Solution Explained - Java

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

ความคิดเห็น • 203

  • @jonathanl3068
    @jonathanl3068 3 ปีที่แล้ว +208

    I love how his submit history is all red

    • @fakeasfluff6842
      @fakeasfluff6842 2 ปีที่แล้ว +21

      relatable

    • @rusty-coder
      @rusty-coder 2 ปีที่แล้ว +2

      Me too, that was very-very relatable.

    • @zo62
      @zo62 ปีที่แล้ว +1

      Lo is like mine

  • @tim37021
    @tim37021 4 ปีที่แล้ว +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.

  • @OctTEN_1010
    @OctTEN_1010 3 ปีที่แล้ว +7

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

  • @Icix1
    @Icix1 5 ปีที่แล้ว +37

    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 ปีที่แล้ว +7

      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

  • @vasujhawar.6987
    @vasujhawar.6987 ปีที่แล้ว +1

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

  • @praveen3791
    @praveen3791 2 ปีที่แล้ว +4

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

  • @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!

  • @anvitabansal5329
    @anvitabansal5329 5 ปีที่แล้ว +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?

  • @leezhenjian7451
    @leezhenjian7451 11 หลายเดือนก่อน

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

  • @shreyavhadadi4887
    @shreyavhadadi4887 4 ปีที่แล้ว +2

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

  • @The2Coolest2
    @The2Coolest2 3 ปีที่แล้ว

    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.

  • @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...

  • @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

  • @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

  • @GuruBala
    @GuruBala 2 ปีที่แล้ว +3

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

  • @danielmcgee2447
    @danielmcgee2447 3 ปีที่แล้ว

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

  • @vikrantbhati6088
    @vikrantbhati6088 4 ปีที่แล้ว +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 []

  • @SHSelect
    @SHSelect 2 ปีที่แล้ว

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

  • @sanyuktakate4099
    @sanyuktakate4099 5 ปีที่แล้ว +2

    This does not remove the duplicates.

  • @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

  • @janhavisanjaybhosle9933
    @janhavisanjaybhosle9933 2 ปีที่แล้ว

    What is the time and space complexity for this?

  • @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

  • @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.

  • @CandyMoney1000
    @CandyMoney1000 4 ปีที่แล้ว +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.

  • @akshayrana9351
    @akshayrana9351 5 ปีที่แล้ว +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

  • @galwije
    @galwije 3 ปีที่แล้ว +1

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

  • @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.

  • @andreas6508
    @andreas6508 4 ปีที่แล้ว +1

    it's still O(n^2) right

    • @codewithjc4617
      @codewithjc4617 4 ปีที่แล้ว

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

  • @augustoalmeida2586
    @augustoalmeida2586 3 ปีที่แล้ว

    Does anyone knows which companies ask for this question?

  • @bethlehemteshome3660
    @bethlehemteshome3660 5 ปีที่แล้ว +10

    Bless your soul

  • @nadaz7333
    @nadaz7333 4 ปีที่แล้ว

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

  • @ankitkohli727
    @ankitkohli727 2 ปีที่แล้ว

    Can anyone explain why a linked list was used?

  • @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.

  • @abiramid4636
    @abiramid4636 4 ปีที่แล้ว +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)

  • @funnytoonz2016
    @funnytoonz2016 2 ปีที่แล้ว

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

    • @kushagrakulshrestha2966
      @kushagrakulshrestha2966 หลายเดือนก่อน

      I think for duplicacy handling (so we compare nth element with it's duplicate (potentially) (n+1)th

  • @taran7649
    @taran7649 2 ปีที่แล้ว

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

  • @krishnabhagat2716
    @krishnabhagat2716 4 ปีที่แล้ว

    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

  • @akritbehera7751
    @akritbehera7751 2 ปีที่แล้ว

    Why i>0? in line 7?

  • @uberandrew123456
    @uberandrew123456 3 ปีที่แล้ว +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

  • @taran7649
    @taran7649 2 ปีที่แล้ว

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

  • @Richard-ok5un
    @Richard-ok5un 4 ปีที่แล้ว +1

    Very clear and great explanation

  • @satyanveshvanapalli9905
    @satyanveshvanapalli9905 3 ปีที่แล้ว

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

  • @darkhorse621
    @darkhorse621 4 ปีที่แล้ว +2

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

  • @ubaidullahaamir9974
    @ubaidullahaamir9974 หลายเดือนก่อน

    using dictionary we do not need to check for all the edge cases.
    def threeSum(self, nums):

    collection={}
    nums = sorted(nums)
    for index in range(len(nums)-2):
    low=index + 1
    high = len(nums)-1
    target = 0 - nums[index]
    while low < high:
    if nums[low] + nums[high] == target:
    temp = (nums[index],nums[low],nums[high])
    if temp not in collection:
    collection[temp] = list(temp)
    low+=1
    high-=1
    elif nums[low] + nums[high] > target:
    high -= 1
    else:
    low += 1
    return collection.values()

  • @nebiyoupaulos9800
    @nebiyoupaulos9800 4 ปีที่แล้ว +4

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

  • @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 5 ปีที่แล้ว

      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.

  • @toekneema
    @toekneema 5 ปีที่แล้ว +4

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

    • @vikramreddy7586
      @vikramreddy7586 4 ปีที่แล้ว +1

      u can use new ArrayList(); also.

  • @warrenwong4518
    @warrenwong4518 3 ปีที่แล้ว

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

  • @leo-kwo
    @leo-kwo 2 ปีที่แล้ว

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

  • @maithreyiprabhu8605
    @maithreyiprabhu8605 4 ปีที่แล้ว +6

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

  • @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

  • @normanteqwon1763
    @normanteqwon1763 3 ปีที่แล้ว

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

  • @ruslansamatov2819
    @ruslansamatov2819 2 ปีที่แล้ว +2

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

  • @vikassharma4780
    @vikassharma4780 4 ปีที่แล้ว

    i think your linkden url is broken here.

  • @antasjain
    @antasjain 4 ปีที่แล้ว

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

  • @abhishekkumargupta3043
    @abhishekkumargupta3043 4 ปีที่แล้ว +2

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

  • @partheshsoni6421
    @partheshsoni6421 4 ปีที่แล้ว +1

    Nicely explained! Well done.

  • @davidj2597
    @davidj2597 5 ปีที่แล้ว +3

    Keep it up. I love your videos

  • @viralindian8326
    @viralindian8326 4 ปีที่แล้ว +3

    Thanks Nick by heart 💓♥️

  • @anantprakashsingh8777
    @anantprakashsingh8777 2 ปีที่แล้ว

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

  • @fortressonahill5860
    @fortressonahill5860 2 ปีที่แล้ว

    that ending was perfect lmao

  • @siddhishah__cse5796
    @siddhishah__cse5796 4 ปีที่แล้ว +1

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

  • @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);
    }

  • @elvinjafarli6257
    @elvinjafarli6257 5 ปีที่แล้ว +1

    Clear explanation! Thank you!

  • @rrsonia10
    @rrsonia10 5 ปีที่แล้ว

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

  • @SnortsOfHappiness
    @SnortsOfHappiness 4 ปีที่แล้ว

    MY BOI AT IT AGAIN

  • @AmanSingh-ji9dm
    @AmanSingh-ji9dm 3 ปีที่แล้ว

    Why did he handle duplicates twice?

  • @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

  • @samsundar6561
    @samsundar6561 3 ปีที่แล้ว

    Great Explanation,Thanks!

  • @sujandvss2612
    @sujandvss2612 3 ปีที่แล้ว

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

  • @georgezuo6462
    @georgezuo6462 4 ปีที่แล้ว +1

    This is awesome, thank you!

  • @taran7649
    @taran7649 2 ปีที่แล้ว

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

  • @shobhitranjan3957
    @shobhitranjan3957 4 ปีที่แล้ว +1

    Good Work!

  • @tyz5313
    @tyz5313 5 ปีที่แล้ว +2

    nice solution!

  • @shashikantkumar5095
    @shashikantkumar5095 4 ปีที่แล้ว +1

    ur great sir!!

  • @brandonnoll5527
    @brandonnoll5527 3 ปีที่แล้ว

    Great solution!

  • @AnilKumar-un1zo
    @AnilKumar-un1zo 3 ปีที่แล้ว

    Great solution brahh.

  • @webknowledge9989
    @webknowledge9989 2 ปีที่แล้ว

    I don't get it

  • @adamajs3836
    @adamajs3836 2 ปีที่แล้ว

    Only devs can get away with saying 3some in workplace

  • @juanguang2076
    @juanguang2076 4 ปีที่แล้ว

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

  • @abhimalyachowdhury7835
    @abhimalyachowdhury7835 3 ปีที่แล้ว

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

  • @arghyamitra3281
    @arghyamitra3281 3 ปีที่แล้ว +1

    [0,0,0] it won't 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

  • @himanshukhanna2589
    @himanshukhanna2589 2 ปีที่แล้ว

    Threesum is similar to twosum -
    Nick White

  • @fakeasfluff6842
    @fakeasfluff6842 2 ปีที่แล้ว +1

    God, this is so confusing still

  • @曹小虎-k4n
    @曹小虎-k4n 5 ปีที่แล้ว

    very excellent, thanks

  • @rhythmjain5331
    @rhythmjain5331 4 ปีที่แล้ว

    good explanation

  • @hashiramasenju293
    @hashiramasenju293 3 ปีที่แล้ว

    the only 3sum i can afford

  • @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 5 ปีที่แล้ว

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

  • @debagniksen7809
    @debagniksen7809 5 หลายเดือนก่อน

    The real world 3 some is not even a problem.

  • @HIOLLJ
    @HIOLLJ 4 ปีที่แล้ว

    Succinctly explained Nick :)

  • @shubhamladha5426
    @shubhamladha5426 4 ปีที่แล้ว

    bro you are awesome

  • @RedHeadphone
    @RedHeadphone 4 ปีที่แล้ว

    Thanks

  • @CleanCoder
    @CleanCoder 4 ปีที่แล้ว

    Awesome !

  • @papaz.z853
    @papaz.z853 2 ปีที่แล้ว

    Like your video. Thanks

  • @montuedge
    @montuedge 3 ปีที่แล้ว

    Was waiting for hashmap...never came

  • @SailaMaham
    @SailaMaham 4 ปีที่แล้ว +4

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