Sort an array of 0's 1's & 2's | Intuition of Algo🔥 | C++ Java Python | Brute-Better-Optimal

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ม.ค. 2025

ความคิดเห็น • 1K

  • @takeUforward
    @takeUforward  ปีที่แล้ว +131

    Let's march ahead, and create an unmatchable DSA course! ❤
    Use the problem links in the description.

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

      This is the consistency we need from you bhai ❤️!

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

      can u post string series

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

      Understood 👍
      You are a legend sir

    • @vikassingh8800
      @vikassingh8800 22 วันที่ผ่านมา

      brother i dont know your name but i wanna share one thing.
      i had taken a course from codingNinjas but i didnt get everything in one go but when i start wathcing your video i always getting everything at a single loop.
      MEans you have given evevrything in your videos what actually a company's requirement.
      Thankyou once again for everything.☺

    • @UdhyaKumar-z4d
      @UdhyaKumar-z4d 6 วันที่ผ่านมา

      Definitely sir

  • @apoorvchaudhary2592
    @apoorvchaudhary2592 ปีที่แล้ว +492

    The best thing about this guy is he's not into dramas. Straight to the point. All 25 minutes are dedicated to the question itself

  • @tanishpahwa4779
    @tanishpahwa4779 ปีที่แล้ว +92

    I don't usually comment on any video but believe me this guy's great explanation forced me to done this

    • @vikas7588
      @vikas7588 ปีที่แล้ว

      Doubt : This is not working for
      0 1 0 2 1 2
      Please help someone.

  • @ashishdhal4614
    @ashishdhal4614 ปีที่แล้ว +144

    Best explanation of Dutch national flag in internet never knew we could think it like this

    • @vikas7588
      @vikas7588 ปีที่แล้ว

      Doubt : This is not working for
      0 1 0 2 1 2
      Please help someone.

  • @siddharthkhandelwal933
    @siddharthkhandelwal933 7 หลายเดือนก่อน +3

    Thanks! Great Explanation

  • @prashanthvaidya
    @prashanthvaidya ปีที่แล้ว +133

    Comparing this to your older videos, there is a much more visible sense of calm in your teaching style. Your communication is spot on as well, with very little pause words etc.
    Kudos to your progress and dedication, Raj. Very inspring! ❤

    • @takeUforward
      @takeUforward  ปีที่แล้ว +62

      You learn, and you grow every day :)

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

      Btw who is Raj ...He is our Striver Bhaiya ....The one and only piece 😂😂🙏🙏🙏🙏

  • @ashutoshkr99
    @ashutoshkr99 ปีที่แล้ว +26

    I'm so regretful that why I haven't found you in my initial engineering years ....things would have been different. Lots of thanks. You are a gem. ❤️

    • @darshanakv4946
      @darshanakv4946 9 หลายเดือนก่อน +2

      same thoughts!

  • @digvijaysingh2709
    @digvijaysingh2709 ปีที่แล้ว +8

    I didn't know about this algorithm and solved the same question by 2 passes . Then I saw the problem in a sheet asking to solve in one pass ....lots of time spent I wanted to get a hint and heard this name DNF algorithm. I tried to read about it in many sites and still couldn't make an intuition out of it. My final option and goto brother for me was you Anna and You made me understand it in just one play that's it I am going to code this now, very thankful to you

  • @brajeshmohanty2558
    @brajeshmohanty2558 ปีที่แล้ว +72

    Time stamp ⏲️
    Course promo:- 0:10
    Problem statement:- 0:48
    Brute force approach:-1:11
    Better approach:- 1:40
    Optimal solution:-4:24
    (Dutch National Flag algo):- 4:44
    Algorithm Dry run:-15:37
    Code implementation:-20:55
    Time and space complexity:- 22:11
    Outro 24:57
    Guys bhai itna effort de rehe hai pls like share and subscribe 🙏😁.
    And bhai ek request hai pls iPad ke notes ka pdf attach kardo na.

    • @takeUforward
      @takeUforward  ปีที่แล้ว +46

      Ipad k notes are not good, this is the reason we are writing articles, soon articles will be updated according to the video.

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

      @@takeUforward Sir, i understand why the mid is there it is at the start of the unsorted array But why we put low on the same index, it may fit right in this case where first element is 0 but what if it was 1 or 2 then where will put the low. It is a small doubt, Rest of it was the best explanation i found.

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

      @@lambslife1802 at the same place....is fits the condition....take such examples and solve... you will get it

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

      @@lambslife1802 because from 0 to low-1 are all zeros. If we think in an unsorted array where low is at start, the elements from 0 to low-1 do not exist so the condition is technically fulfilled. (Mentioned in the video)

  • @PrasunKBasak
    @PrasunKBasak ปีที่แล้ว +16

    This guy is putting so much efforts for us. Thanks striver.

  • @manipandit18
    @manipandit18 ปีที่แล้ว +12

    Never knew this intuition before !!! Understood
    Time Stamp :
    0:40 - Problem Explanation
    1:08 - Brute Force
    1:40 - Better Solution
    4:30 - Optimal Solution (DNF Algorithm)
    5:10 - Intuition behind algorithm
    15:35 - Dry Run
    20:55 - Code
    22:10 - Time Complexity

  • @crazybro4383
    @crazybro4383 10 หลายเดือนก่อน +3

    Sirf diagram se pura algorithm khud hi samajh aa gya, you are an amazing teacher. Thank you for providing such great content for free.

  • @md.ualiurrahmanrahat2400
    @md.ualiurrahmanrahat2400 ปีที่แล้ว +4

    Saw a few tutorials on DNF sort before. But no one has explained the intuition behind it. What a video this is!!! Thank you Striver for such amazing explanation. God Bless you.

  • @yasaswinikarumuri9590
    @yasaswinikarumuri9590 10 หลายเดือนก่อน +2

    mind blowing. Understood DNF algo clearly for the first time. Thanks Striver!

  • @066_varshamalyan9
    @066_varshamalyan9 ปีที่แล้ว +7

    This video clarified my concepts about this algorithm much better than I had before. Thank you so much for delivering the best quality knowledge. ❤❤

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

    Thanks!

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

    Really great video, I have done this question a few times but this is the first time, I understood the concept behind it. Thanks a lot striver for explaining it in so detail.

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

    Understood . Love from Haryana. ❤❤❤❤

  • @PrinceYadav-ll8hs
    @PrinceYadav-ll8hs ปีที่แล้ว +3

    Best explanation i have ever seen for this dutch algorithm ❤

  • @learner3206
    @learner3206 9 หลายเดือนก่อน +1

    The update of your website :) mind blowing sir!

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

    Next Level Explaination...!
    Thank you so much..❤❤❤

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

    understood😌,the optimal approach explanation was mind blowing.

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

    bhai yaar kya hi video banaya yr... even paid courses dont explain concepts with this much depth... thanks!!!

  • @ziggywiggys
    @ziggywiggys 9 หลายเดือนก่อน +3

    My Goodness Bro !!
    How do you even come up with this kind of an intuition ?
    Absolutely Mind Boggling, especially the diagram.
    That is what the crux of the intuition is behind the Algorithm.
    Hats off and thanks for making it so easy to understand.
    Thanks

  • @ArpanChakraborty-do6yz
    @ArpanChakraborty-do6yz ปีที่แล้ว +1

    understood,, really bhaiya you are just amazing ❤❤love from westbengal😊😊

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

    Hey Striver, I am currently pursuing my master in CSE in IIT Guwahati...The way you teach is just amazing, currently following your DSA sheet....

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

      how are the placements there after mtech?

  • @dipjyotinath2352
    @dipjyotinath2352 16 วันที่ผ่านมา +1

    Thank you bro...I just can not explain my feeling after watching this video. You have made this problem so easy for my which was impossible to understand for me earlier.

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

    Your effort into each video was incredible, and I am so glad to have found your course Thank you, Raj❤

  • @subhamagarwal476
    @subhamagarwal476 9 หลายเดือนก่อน +1

    never seen such an amazing explanation to this problem. Thank you striver

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

    The dedication you put for the us is very high when compared to the dedication we put for ourselves!!thank you so much

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

    This video really deserves a like yaar. Kya mast intuition diya hai. Khud hi dry run karlia khud hi code karlia. Thank you sir. Much appreciated.

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

    SDE Sheet Day 1 Problem 5 Done!

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

    Gold Content. Direct into brain. UNDERSTOOD

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

    Hey everyone, welcome back to the channel, I hope you guys are doing extremely well.... this is my favorite dialogue
    😅😅😅😅😅

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

    Man, I love everything you're doing! Salut from Egypt! You're definitely helping poor people with ambition from all over the world!

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

    There's a mistake in algo of better solution at
    Timestamp: 3:16
    Initially count_0 = 0, count_1 = 0 and count_2 = 0 instead of count_0 = 0, count_1 = 1, count_2 = 2

  • @rajatshukla2605
    @rajatshukla2605 4 หลายเดือนก่อน +1

    Understood!
    Elegantly explained!

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

    i'm in love with ur teaching style ........

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

    THANK YOU FOR THIS BEATIFUL VIDEO UNDERSTOOD !!!!!

  • @sonalisingh7932
    @sonalisingh7932 2 หลายเดือนก่อน +1

    Amazing content. Understood the concept very welll.

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

    yaar just awesome 😍 as like you said, nowhere on TH-cam, the explanation like you is taught..Yes, it's true 💯

  • @samreenimam8608
    @samreenimam8608 11 หลายเดือนก่อน +2

    Thank you so much Striver.. now I'm able to visualize the increments and decrements...amazingly solved!!

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

    Awesome explanation ❤🔥

  • @not_your_Tridiiib
    @not_your_Tridiiib 3 หลายเดือนก่อน +1

    I was strugging to get the intuition of DNF algorithm but after watching your explanation I can proudly say that I will never forget this agorithm,thankns a lot TUF for this goooooood explanation,the way you teach is so calming and you know how to teach like a responsible teacher❤❤❤❤❤

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

    It was fun understanding it that too at midnight 1:00 AM (not even feeling sleepy)

  • @torishi82
    @torishi82 6 หลายเดือนก่อน +1

    Brillian bhai. Thank you.

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

    This is pretty easily the best explanation of the algorithm on YT imo.

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

    There can't exist a better explanation than this for DNF 😊❤

  • @Rudraksx
    @Rudraksx 6 หลายเดือนก่อน +1

    Such crisp explanation with such simplicity, mind boggling!

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

    For the first time, I ever understood Dutch Algo. Thanks for you efforts❤

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

    Even the paid courses wouldn't teach this depth.
    I'm following your course sheet @take U forward You are the best.

  • @jeet-smokey
    @jeet-smokey 10 หลายเดือนก่อน

    Seedhi baat.....no bakwas.....Kudos to your efforts Striver.

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

    Understood, 🚀🚀🚀🚀 Thank you so much striver

  • @krishnagavas6163
    @krishnagavas6163 11 หลายเดือนก่อน +1

    What a beautiful algorithm, and beautifully explained. Kudos to you Striver.

  • @shayo76
    @shayo76 11 หลายเดือนก่อน +2

    first 1min of video boost my energy level to much high 😊😊
    if u complete this course you can solve any question of
    DSA tqq tqqq so much for this content

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

    Thank you so much ❤

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

    Best DNF Explanation ever !!!!

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

    awesome bhaiyya❤❤❤

  • @tamilmukbang3789
    @tamilmukbang3789 9 หลายเดือนก่อน +1

    understood.thank you

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

    literally a hero material.

  • @MANYAVAr-21
    @MANYAVAr-21 หลายเดือนก่อน

    its been 2 weeks since i started this playlist ,still my interest to watch and continue learning remained same .Never have i ever into a playlist this much long on my own .Tq striver👏

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

    Understood✅🔥🔥

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

    No lag..direct to the point❤. THANK YOU SO MUCH.😊

  • @messiisthebest
    @messiisthebest 9 หลายเดือนก่อน +2

    just wanna say, i am imagining like a pro after learning this algorithm

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

    Understood 🔥🔥🔥

  • @Pravenkumar.D
    @Pravenkumar.D 5 หลายเดือนก่อน

    Crystal clear explanation in each and every step ......Awesome DSA course i had ever seen🔥🔥

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

    Implemented the code using a[high] and it got executed correctly, thanks!❤

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

    One of the best explanations to the approach so far...Fantastic

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

    This has to be the best explanation of DNF ! All other videos i saw just runs three pointer and solves the problem but never explains the intuition

  • @utkarshpant5297
    @utkarshpant5297 ปีที่แล้ว

    This is by far the best explanation of this algorithm I've seen anywhere.

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

    Arey sir🙏🙏🙏🙏🤐🤐🤐i am speechless ....just one thing i want to say.#God of DSA

  • @RohitSingh-sb3sw
    @RohitSingh-sb3sw ปีที่แล้ว +1

    Wonderfully explained the Algorithm !
    DSA God The Striver
    Much Love Man !

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

    I have seen the one pass algorithm before but this time I get to know the intuition.
    Thanks bhaiya this if f****** amazing.❤

  • @md_abdulrahman
    @md_abdulrahman 8 หลายเดือนก่อน +1

    Greatly Explained! Thanks

  • @MusaafirSonu
    @MusaafirSonu 5 หลายเดือนก่อน +1

    I generally do not comment of his any lectures but today i literally solved the leetcode question of this topic without seen the code after watching this lecture....
    Thanks a lot striver for this worth watching lecture series and the main thing is that this playlist are of free of cost and giving us millions of paid content...❤

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

    Started your DSA course.Thoroughly enjoying your course from the start.Thank you for helping us😊

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

    best explanation ever watched.

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

    Thank you striverr ,i understood the optimal solution 💙💫

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

    What an explanation! This guy is spot on every time! I could visualize the sorting so clearly and easily!

  • @bhavithasb9445
    @bhavithasb9445 ปีที่แล้ว

    The best part of this entire video is the Intuition, at the first I thought why is he explaining this because I have never heard of it, but exactly while doing the code...I was getting that intuition in my mind...ok I am swapping low and mid like this....and that hypothetical array diagram is flashing in my mind...Thank you so much striver bro....your videos are helping a lot at a time like this!!!!

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

    Started practicing recently and I would say one of the best channel for practicing DSA.
    Great work, keep it up. I see in TUF for some questions they are marked as video will be uploaded soon.
    Please record and upload them, thank you

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

    Big fan of his teaching style. Too good. Best DSA Course in the world

  • @per.seus._
    @per.seus._ ปีที่แล้ว +2

    UNDESTOOD❤

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

    Amazing video Bhaiya! Ye logic hi to chahiye tha 😊

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

    Extremely well explained! UNDERSTOOD :)

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

    So far the best teacher who explains the algorithm and intuition behind it. Kudos to you Raj. fan of your dedication and the hard work you are putting in to help people.♥♥. Thanks for the amazing content and everything.

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

    I have never visualize your any content the way I visualize this, awesome!! ❤❤❤❤

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

    whatta optimal approach.....my mind really blew away!!!!

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

    Great video !

  • @the.harisankar
    @the.harisankar 2 หลายเดือนก่อน

    if i had an option to like this video 1000 times, I would do it. Thank you, broo!! such a nice explanation.

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

    Just Wow!! No words can explain how knowledgable this guy is !!🤩🙌

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

    You blow my mind by making everything look so simple!!

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

    Understood❤‍🔥❤‍🔥

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

    I am surprised, the way of explaining. 👏👏. Understood clearly.

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

    The way you teach is very clearly understandable . When we go outside the way you teach, you provide things other may charge 5 to 10 k for this knowledge but still you giving it freely . Thank You so much sir 🥳🥳🥳🥳

  • @divyanjalinaidu6209
    @divyanjalinaidu6209 3 วันที่ผ่านมา

    Thanks, bro! I thought this algorithm would be tough because of its name, but the way you explained it made it super easy to understand. Appreciate it!

  • @somnathkarmakar-q8y
    @somnathkarmakar-q8y ปีที่แล้ว +1

    Agunn puro 🔥

  • @avneeshsawhney5890
    @avneeshsawhney5890 2 วันที่ผ่านมา

    Understood and thank you very much for making this so easy and for the efforts you put in the video

  • @CHJOHN-m9p
    @CHJOHN-m9p 6 หลายเดือนก่อน

    the optimal method really mind blowing . after watching video for 25 min the optimal code feels like easy one. His dedication levels 🙌

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

    Absolutely brilliant explanation. You are making one fall in love with coding. Thank you for all your efforts. We are so grateful to u.