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

  • @takeUforward
    @takeUforward Жыл бұрын

    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

    @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

    @deepak8720

    Жыл бұрын

    Awesome stuff. Liked and subscribed. Keep going. 👍

  • @pardhi8959

    @pardhi8959

    10 ай бұрын

    great content love u bhai

  • @pardhi8959

    @pardhi8959

    10 ай бұрын

    I start by like for all the video

  • @Bhai9866

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

  • @luckshaeey
    @luckshaeey Жыл бұрын

    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

    @rishav144

    Жыл бұрын

    true bro

  • @it-51gulshanbhati89

    @it-51gulshanbhati89

    Жыл бұрын

    u r strong bro u have tried all as a beginner 😅

  • @Akash-yr2if

    @Akash-yr2if

    Жыл бұрын

    You have a lot more experience than the whole comment section combined.

  • @user-ye4xi4py2k

    @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

    @joeljacob4685

    11 ай бұрын

    @@user-ye4xi4py2k yup !! you are right

  • @shashankrajput8084
    @shashankrajput80842 ай бұрын

    That's what a explanation beginner require for these type of problems

  • @itzmartin20
    @itzmartin209 ай бұрын

    Just cameback for a quick revision, and now it's indeed got into my head, thanks for your crystal clear intuition!

  • @mehulthuletiya497
    @mehulthuletiya497 Жыл бұрын

    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

  • @Pamir026
    @Pamir02611 ай бұрын

    Yes! I was onto this optimal approach but my implementation failed because I wasn't thinking it through. Simply lovely explanation!

  • @deepak8720
    @deepak8720 Жыл бұрын

    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. 👍

  • @subhranshuswayampravadash4656
    @subhranshuswayampravadash4656 Жыл бұрын

    Thanks brother for helping and providing us amazing solutions of the most important questions that asked in MNC's. Thanks a lot brother🙏

  • @pragyatripathi8833
    @pragyatripathi8833 Жыл бұрын

    I love the way you teach bhayiya.❤❤ I don't have seen the teacher like you....you are God of DSA.

  • @abhijeetmishra3804
    @abhijeetmishra38049 ай бұрын

    how can one explain so smoothly man...Hats of STRIVER bhaiya

  • @cinime
    @cinime Жыл бұрын

    Understood! Super amazing explanation as always, thank you very much for your effort!!

  • @PrashantSingh-qr3vn
    @PrashantSingh-qr3vn11 ай бұрын

    Are u a genius how do u know what doubts a newbie would have . U r just superb in explaining the Algo

  • @jeet-smokey
    @jeet-smokey4 ай бұрын

    We will never get such a detailed explanation of 3 Sum problem. You are a Legend for reason....Striver.....!!!!

  • @ruchikaahujaasm
    @ruchikaahujaasm3 ай бұрын

    Explained all 3 approaches very clearly. Thank you so much!!!

  • @rajatyadav4077
    @rajatyadav4077Ай бұрын

    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

    @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

    @user-hp9kj8qt1h

    23 күн бұрын

    Me too pls

  • @graviton001

    @graviton001

    7 сағат бұрын

    I also solved with two pointer approach on my own after 3 loops got time exceeded 😊 he built my logical thinking

  • @Manishgupta200
    @Manishgupta200 Жыл бұрын

    Thanks for the in-depth explaination with in-depth time and space complexity

  • @sharmavishal7239
    @sharmavishal7239 Жыл бұрын

    Bhai maine aapki dsa sheet aaj first time dekhi hai kya banayi hai bhai , sach main mja aa gya .... Thanku dil se striver bhai ❤

  • @swathigp3818
    @swathigp38182 ай бұрын

    Great examples, which helps understand the algorithm very clearly even for non CSE folks!!

  • @trinitykhuman
    @trinitykhuman7 ай бұрын

    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.

  • @AmartyaPardeshi
    @AmartyaPardeshi11 ай бұрын

    My man is doing God's work, thanks for this amazing playlist!

  • @disciplines4
    @disciplines4 Жыл бұрын

    nice all the three approaches, helped a lot.

  • @sdakshin1
    @sdakshin12 ай бұрын

    I found your explanation the best among all available... gd job

  • @RahulKumar-zp1ln
    @RahulKumar-zp1ln11 ай бұрын

    THANK YOU FOR EXPLANING IN SIMPLE WAY

  • @ahssanakhtar5746
    @ahssanakhtar5746Ай бұрын

    Amazing content learn a lot every day from your course.Thanks for creating such an amazing course.

  • @welcometoc.s.easpirants
    @welcometoc.s.easpirants7 ай бұрын

    Awesome explaination. Thank u for such a great content.

  • @piyushroy3278
    @piyushroy327820 күн бұрын

    Too good man, more and more kudos to you for such explanation. now im getting grip on building logic...finally.

  • @jingfulin2322
    @jingfulin23223 ай бұрын

    Great job! your code is so clean.

  • @rohansingh6329
    @rohansingh632911 ай бұрын

    awsm video striver ❤❤ the free education you are providing is helping a us alot.

  • @user-bj9qx9yf1o
    @user-bj9qx9yf1o11 ай бұрын

    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.

  • @S__Arslaan
    @S__Arslaan9 ай бұрын

    no need of condtion j

  • @eashan2405
    @eashan240511 ай бұрын

    Great explanation Striver ❤

  • @Bakwas_baate
    @Bakwas_baateАй бұрын

    what a solution. MINDBLOWING!!!!

  • @dipingrover1970
    @dipingrover19704 ай бұрын

    amazing exlanation , loved this video

  • @joeljacob4685
    @joeljacob468511 ай бұрын

    Beautiful dry run!! Understood😄

  • @culeforever5408
    @culeforever54089 ай бұрын

    understood and came up with the optimal solution myself almost same. just used an extra set to store triplets 😅

  • @user-yz6yk4vt6q
    @user-yz6yk4vt6q4 ай бұрын

    what a fantastic explantion!!!!

  • @priyanshuagrawal7509
    @priyanshuagrawal75098 ай бұрын

    Now i can finally answer someone if someone ask me have you done 3Sum 😆. Thanks Striver 😉

  • @rahulraaja5056
    @rahulraaja505610 ай бұрын

    Great Explanation 💯💯

  • @gamingchampions4105
    @gamingchampions41059 ай бұрын

    gained a subscriber with your amazing explanation

  • @JackCoderr
    @JackCoderr Жыл бұрын

    Thank you so much bhaiya....you are the best teacher ❤❤❤

  • @sarangkumarsingh7901
    @sarangkumarsingh79014 ай бұрын

    Another Awesome Lecture................

  • @tanya8353
    @tanya83537 ай бұрын

    Great Job again !!

  • @anjigolla4853
    @anjigolla4853 Жыл бұрын

    superb explanation brother👏

  • @sayakghosh5104
    @sayakghosh5104 Жыл бұрын

    Awesome explanation....

  • @samlinus836
    @samlinus836 Жыл бұрын

    Thank you bro, love from Tamil Nadu ❤

  • @Benstokes555
    @Benstokes5556 ай бұрын

    mind blown, dopamine released, love u striver

  • @udaytewary3809
    @udaytewary3809 Жыл бұрын

    Understood bhaiya 🙏 ❤️

  • @bopon4090
    @bopon40903 ай бұрын

    Bro that hash map solution is so genius.

  • @a1_32_aarushi8
    @a1_32_aarushi8 Жыл бұрын

    Thank you so much sir for such a nice explanation your are super sir❤

  • @guneeshvats46
    @guneeshvats4616 күн бұрын

    Amazing explanation

  • @anasnadeem3259
    @anasnadeem325911 ай бұрын

    Great explanation 💯

  • @Azeem_Idrisi
    @Azeem_Idrisi Жыл бұрын

    Amazing explanation 👌💯

  • @souravmehraniya2832
    @souravmehraniya2832 Жыл бұрын

    Keep going brother ❤

  • @newbie8051
    @newbie80512 күн бұрын

    Was asked in Adobe interview for DEI hiring for specially abled candidates. Woah, thanks !

  • @hashcodez757
    @hashcodez7572 ай бұрын

    Mza aagya Understood!!

  • @priyankaghosh2670
    @priyankaghosh2670 Жыл бұрын

    best teacher in the world...........

  • @AbhishekKumar-nz9dn
    @AbhishekKumar-nz9dn10 ай бұрын

    understood brilliantly 😘

  • @tarunsingh7826
    @tarunsingh7826 Жыл бұрын

    Best explanation 🔥

  • @arunprashanna7494
    @arunprashanna749411 ай бұрын

    Perfect explanation

  • @manvendrasingh4369
    @manvendrasingh4369Ай бұрын

    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.

  • @GhostVaibhav
    @GhostVaibhav5 ай бұрын

    Understood🔥

  • @NazeerBashaShaik
    @NazeerBashaShaik3 ай бұрын

    Understood, thank you.

  • @UECAshutoshKumar
    @UECAshutoshKumarАй бұрын

    Understood 👍

  • @konankikeerthi
    @konankikeerthiАй бұрын

    Understood bro. Thank you

  • @aditikaushik3073
    @aditikaushik3073 Жыл бұрын

    Thanks a lot, sir !!

  • @dpxy1599
    @dpxy159910 ай бұрын

    got it nicely explained.

  • @swacharahman5084
    @swacharahman5084 Жыл бұрын

    Thank you bhaiya, Love from bangladesh

  • @bitran4283
    @bitran428310 ай бұрын

    love it, thanks

  • @RituSingh-ne1mk
    @RituSingh-ne1mk7 ай бұрын

    Understood!

  • @AniketKumar-hf2bo
    @AniketKumar-hf2bo5 ай бұрын

    understood ,thnx for explanation ❤❤❤❤❤❤👌👌💕💕💕💕

  • @user-xv7ms8bn2b
    @user-xv7ms8bn2bАй бұрын

    best explaination !!!

  • @shubhamkumar170
    @shubhamkumar17010 ай бұрын

    Understood!! ❤❤

  • @manambalaji9547
    @manambalaji95478 ай бұрын

    Excellent 👌

  • @user-if3ce9gm7p
    @user-if3ce9gm7p25 күн бұрын

    Understood sir thank you soo much sir

  • @lakshmiprasanna7058
    @lakshmiprasanna7058 Жыл бұрын

    Understood 💯💯💯

  • @parthtiwari8152
    @parthtiwari815211 ай бұрын

    understood thanks striver

  • @YourCodeVerse
    @YourCodeVerse9 ай бұрын

    Understood✅🔥🔥

  • @sayantanpoddar5428
    @sayantanpoddar54288 ай бұрын

    understood!!! please came up with string series...please

  • @secretvibz6300
    @secretvibz63006 ай бұрын

    As Smooth as Butter 😃

  • @Sumeet_100
    @Sumeet_1003 ай бұрын

    Thank you ❤

  • @saketjaiswal9381
    @saketjaiswal938111 ай бұрын

    thank us sir again

  • @sakshiagrawal9106
    @sakshiagrawal91064 ай бұрын

    thank you so much bhaiya❤

  • @rishav144
    @rishav144 Жыл бұрын

    God of DSA❤

  • @vishalgupta7522
    @vishalgupta7522 Жыл бұрын

    Line 29: Char 10: error: type 'vector' does not provide a call operator ans(st.begin(), st.end()); ^~~ 1 error generated. brute force code

  • @senseiAree
    @senseiAree10 ай бұрын

    Understood ❤

  • @abhishekverma9946
    @abhishekverma9946 Жыл бұрын

    Understood.🙂

  • @her_soulmate
    @her_soulmate10 ай бұрын

    Understood 🎉

  • @anmjubaer
    @anmjubaer8 ай бұрын

    Great explanation but what about the time complexity of those 2 while loops from the optimal solution? Can you elaborate a bit here please?

  • @SatheeshKumar-kg1yn
    @SatheeshKumar-kg1yn4 ай бұрын

    Clealy understood

  • @anantsingh2004
    @anantsingh2004 Жыл бұрын

    Understood😊

  • @firebout7675
    @firebout76757 ай бұрын

    understoood

  • @VishalPanwar-df5ek
    @VishalPanwar-df5ek Жыл бұрын

    Understood man !!!!!!!!!!!!!!!!!!

  • @amankumar5230
    @amankumar523010 ай бұрын

    Sir, Please continue your solution videos for A-Z DSA course

  • @Shivi32590
    @Shivi3259015 күн бұрын

    thank you

  • @per.seus._
    @per.seus._ Жыл бұрын

    understood❤

  • @nightgamer8953
    @nightgamer89538 ай бұрын

    HashSet in C# still stores duplicate List in C# . Is there any alternatives in C# to store unique List of Integers?

  • @user-nk1mb5fy7j
    @user-nk1mb5fy7j Жыл бұрын

    UNDERSTOOD

  • @user-uv5or5bm2c
    @user-uv5or5bm2c5 ай бұрын

    Understood.

  • @KulvinderSingh-pm7cr
    @KulvinderSingh-pm7cr Жыл бұрын

    very helpful

  • @arnavumarkar8259
    @arnavumarkar8259 Жыл бұрын

    Thank You