3 Sum | Brute - Better - Optimal with Codes
Problem Link: bit.ly/3X34JSI
Notes/C++/Java/Python codes:
We have solved the problem, and we have gone from brute force and ended with the most optimal solution. Every approach's code has been written in the video itself. Also, we have covered the algorithm with intuition.
Full Course: bit.ly/tufA2ZYt
You can follow me across social media, all my handles are below:
Linkedin/Instagram/Telegram: linktr.ee/takeUforward
0:00 Introduction of Course
00:41 Problem Statement
02:56 Brute force approach (Using 3-pointer)
04:55 Pseudocode
07:36 Code
09:27 Complexity
10:26 Better approach (Using Hashing)
12:23 Dry run
18:09 Code
20:15 Complexity
22:20 Optimal approach (Using 2-pointer)
23:20 2-Pointer Technique
31:50 Code
36:41 Complexity
Пікірлер: 324
Please do give us a like and subscribe, it won't cost you anything, but it will motivate me to make such kind of content more and more.
@utsavseth6573
Жыл бұрын
Legendary stuff Raj bhai. Your explanation clearly shows you actually have a very strong depth on these fundamentals. And of course you do, you work for Google😉
@deepak8720
Жыл бұрын
Awesome stuff. Liked and subscribed. Keep going. 👍
@pardhi8959
10 ай бұрын
great content love u bhai
@pardhi8959
10 ай бұрын
I start by like for all the video
@Bhai9866
9 ай бұрын
Bhaiya code nhi chal raha hai 3 sum ki u give the condition sum is greater than 0 , less than 0 but didn't give the condition sum is equal to 0 why?
Tried 2 sum, 3 sum and 4 sum problems together as a beginner. It was so frustrating after a point before I understood the optimal approach 😂
@rishav144
Жыл бұрын
true bro
@it-51gulshanbhati89
Жыл бұрын
u r strong bro u have tried all as a beginner 😅
@Akash-yr2if
Жыл бұрын
You have a lot more experience than the whole comment section combined.
@user-ye4xi4py2k
11 ай бұрын
The optimal approach for 3sum is just the extension of optimal approach of 2 sum when the array given is sorted
@joeljacob4685
11 ай бұрын
@@user-ye4xi4py2k yup !! you are right
That's what a explanation beginner require for these type of problems
Just cameback for a quick revision, and now it's indeed got into my head, thanks for your crystal clear intuition!
00:41 Problem Statement 02:56 Brute force approach (Using 3-pointer) 04:55 Pseudocode 07:36 Code 09:27 Complexity 10:26 Better approach (Using Hashing) 12:23 Dry run 18:09 Code 20:15 Complexity 22:20 Optimal approach (Using 2-pointer) 23:20 2-Pointer Technique 31:50 Code 36:41 Complexity
Yes! I was onto this optimal approach but my implementation failed because I wasn't thinking it through. Simply lovely explanation!
Completely Understood your explanation! Thank you for what you are doing, and please continue the good work. You are an amazing teacher. Have watched 3 videos of yours and I was able to understand all 3 with out any confusions. Big thumbs up for the video. 👍
Thanks brother for helping and providing us amazing solutions of the most important questions that asked in MNC's. Thanks a lot brother🙏
I love the way you teach bhayiya.❤❤ I don't have seen the teacher like you....you are God of DSA.
how can one explain so smoothly man...Hats of STRIVER bhaiya
Understood! Super amazing explanation as always, thank you very much for your effort!!
Are u a genius how do u know what doubts a newbie would have . U r just superb in explaining the Algo
We will never get such a detailed explanation of 3 Sum problem. You are a Legend for reason....Striver.....!!!!
Explained all 3 approaches very clearly. Thank you so much!!!
It's interesting-I initially tackled this problem with three nested loops, but when the time exceeded, I decided to find a way to eliminate one loop and ended up developing a two-pointer solution. Although I found the solution, I still enjoy watching Striver's videos to refresh my mind, spark creativity, and discover new approaches to problem-solving.
@karthikeyan.s2565
27 күн бұрын
Bro 3 loops was the best I could think of, I can't able to optimize it How do you develop this logical thinking ? Could you help me with this ?
@user-hp9kj8qt1h
23 күн бұрын
Me too pls
@graviton001
7 сағат бұрын
I also solved with two pointer approach on my own after 3 loops got time exceeded 😊 he built my logical thinking
Thanks for the in-depth explaination with in-depth time and space complexity
Bhai maine aapki dsa sheet aaj first time dekhi hai kya banayi hai bhai , sach main mja aa gya .... Thanku dil se striver bhai ❤
Great examples, which helps understand the algorithm very clearly even for non CSE folks!!
I was looking for brute force approach tried myself but couldn't remember I have to used set DS but now , I can understand where I was wrong. Thanks for the tutorial.
My man is doing God's work, thanks for this amazing playlist!
nice all the three approaches, helped a lot.
I found your explanation the best among all available... gd job
THANK YOU FOR EXPLANING IN SIMPLE WAY
Amazing content learn a lot every day from your course.Thanks for creating such an amazing course.
Awesome explaination. Thank u for such a great content.
Too good man, more and more kudos to you for such explanation. now im getting grip on building logic...finally.
Great job! your code is so clean.
awsm video striver ❤❤ the free education you are providing is helping a us alot.
Hi, you are doing extremely good work DSA topics. You making concepts very clear. Glad that I got your channel reference. But un luckily I am from JavaScript background , i am finding a resources like anything for DSA, I dint get any . Your help will be appreciated on this.
no need of condtion j
Great explanation Striver ❤
what a solution. MINDBLOWING!!!!
amazing exlanation , loved this video
Beautiful dry run!! Understood😄
understood and came up with the optimal solution myself almost same. just used an extra set to store triplets 😅
what a fantastic explantion!!!!
Now i can finally answer someone if someone ask me have you done 3Sum 😆. Thanks Striver 😉
Great Explanation 💯💯
gained a subscriber with your amazing explanation
Thank you so much bhaiya....you are the best teacher ❤❤❤
Another Awesome Lecture................
Great Job again !!
superb explanation brother👏
Awesome explanation....
Thank you bro, love from Tamil Nadu ❤
mind blown, dopamine released, love u striver
Understood bhaiya 🙏 ❤️
Bro that hash map solution is so genius.
Thank you so much sir for such a nice explanation your are super sir❤
Amazing explanation
Great explanation 💯
Amazing explanation 👌💯
Keep going brother ❤
Was asked in Adobe interview for DEI hiring for specially abled candidates. Woah, thanks !
Mza aagya Understood!!
best teacher in the world...........
understood brilliantly 😘
Best explanation 🔥
Perfect explanation
While solving this problem, the very first approach which comes to my mind was optimal. Although the way I was handling duplicates was giving time limit exceeded error so I have to took help from gpt but rest of the logic was correct. Feeling extremely happy.
Understood🔥
Understood, thank you.
Understood 👍
Understood bro. Thank you
Thanks a lot, sir !!
got it nicely explained.
Thank you bhaiya, Love from bangladesh
love it, thanks
Understood!
understood ,thnx for explanation ❤❤❤❤❤❤👌👌💕💕💕💕
best explaination !!!
Understood!! ❤❤
Excellent 👌
Understood sir thank you soo much sir
Understood 💯💯💯
understood thanks striver
Understood✅🔥🔥
understood!!! please came up with string series...please
As Smooth as Butter 😃
Thank you ❤
thank us sir again
thank you so much bhaiya❤
God of DSA❤
Line 29: Char 10: error: type 'vector' does not provide a call operator ans(st.begin(), st.end()); ^~~ 1 error generated. brute force code
Understood ❤
Understood.🙂
Understood 🎉
Great explanation but what about the time complexity of those 2 while loops from the optimal solution? Can you elaborate a bit here please?
Clealy understood
Understood😊
understoood
Understood man !!!!!!!!!!!!!!!!!!
Sir, Please continue your solution videos for A-Z DSA course
thank you
understood❤
HashSet in C# still stores duplicate List in C# . Is there any alternatives in C# to store unique List of Integers?
UNDERSTOOD
Understood.
very helpful
Thank You