3Sum | LeetCode 15 | C++, Java, Python

preview_player
Показать описание

**** Best Books For Data Structures & Algorithms for Interviews:**********
*****************************************************************************

July LeetCoding Challenge | Problem 8 | 3Sum | 8 July,
Facebook Coding Interview question,
google coding interview question,
leetcode,
3Sum,
3Sum c++,
3Sum Java,
3Sum python,
3Sum solution,
15. 3Sum,

#CodingInterview #LeetCode #JulyLeetCodingChallenge #Google #Amazon #3Sum
Рекомендации по теме
Комментарии
Автор

I always look for your explanation it is crisp and clear !!

bittupandey
Автор

2 pointer approach is awesome. But sir can we do it with DP...? I spent 3 hours in it....I even took 4D DP array but but didn't get correct solution. It was easily done with the help of (coin change) recursion.

mukultaneja
Автор

Hi
Won' t the logic you explained for 2-SUM change the indices post sorting? In order to use the left-right logic, we need to sort the array. Once sorted, the indices will get updated. So the i and j will reflect indices of sorted array not the original array.
Can you please clarify?

praveen
Автор

Thanks a lot! helps me figur out how to code it.

jlo
Автор

Amazing !! Loved this Time order and code together thank you

Mr.Starmaker
Автор

Awesome video sir!!!
Keep posting them

rishisharma
Автор

Thankyou for the effort. You explained it really well.

emanejaz
Автор

Thank you so much for a simpler solution!!!

senthilkumar
Автор

Just one doubt: In python code - Line 17 - i had written 'if' instead of 'elif' and one tc was failing. What diff it will make?
because all 3 conditions are different right i.e summ == 0, summ < 0 and summ > 0 so anyway only either of these should execute. (btw we've to use summ not sum as var name - bcoz sum is keyword in python)

adarshmv
Автор

Thank you well explained👍 and we'll coded too I didn't knew the use of this -> {} operator in vector but now I do. Thanks to you👌

kushaalrana
Автор

Gajab search for one element in sorted array takes logn time

anishsuman
Автор

Thanks, This is the strategy I used as well, though I couldn't do better than 43% on the time. Maybe because I did the 2sum part as a separate function and in JS.
Anyhoo, here's a possible optimization (right after line 9 in the C++ code):
if(nums[i] > 0) break;

ehilr

crankyinmv
Автор

while(j < k && nums[j] == nums[j+1]) j++;
while(j < k && nums[k] == nums[k-1]) k--;
Can someone explain me what is the use these 2 while loops?

naidusunny
Автор

2 while condition we are checking for sum==0.... We could check these conditions for sum>0 and sum<0

anandmishra
Автор

Thanks for the explanation. Always i skip the problem..Now always i have to attain... :)

pratyushranjansahu
Автор

How could i reach u, either give yours Instagram handle or linkedin profile

TechWithKomal
join shbcf.ru