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

Поділитися
Вставка
  • Опубліковано 11 вер 2024

КОМЕНТАРІ • 806

  • @takeUforward
    @takeUforward  Рік тому +2

    Please watch our new video on the same topic: ua-cam.com/video/tp8JIuCXBaU/v-deo.html

  • @takeUforward
    @takeUforward  4 роки тому +40

    Please watch the new video which covers it in more depth, and also prints it: ua-cam.com/video/tp8JIuCXBaU/v-deo.html
    Watch the video, and leave one of the either comments "understood" or "not understood" !
    If you appreciate the channel's work, you can join the family: ua-cam.com/channels/JskGeByzRRSvmOyZOz61ig.htmljoin

    • @deveshvishwakarma23
      @deveshvishwakarma23 4 роки тому +3

      Giving back to the community is one of the best work you can do, just wait for few more years and people joining in the biggest companies will proudly say that Striver taught us how to think and code! 💯

    • @rohithchittibommala2002
      @rohithchittibommala2002 4 роки тому +1

      after watching your explanation I was able to code without looking your code😀😀😀😀😀

    • @japneetsingh1336
      @japneetsingh1336 4 роки тому +3

      Can you upload more videos or increase the upload frequency ... Because the video quality is awesome 👌.. each strategy is very well explained...

    • @chinmaymanas2054
      @chinmaymanas2054 4 роки тому

      Understood

    • @hareeshr3979
      @hareeshr3979 4 роки тому +2

      @@japneetsingh1336 he's working so that's not possible . we must understand his situations too right ?

  • @littleleaf9699
    @littleleaf9699 2 роки тому +31

    2 years later. Still the best place to learn. Thank you striver

  • @whocares7557
    @whocares7557 3 роки тому +59

    Great explanation as always, thanks❤️
    Also a small intuition add-on for those who are wondering why we aren't incrementing mid when we encounter a 2 by it: the value that high holds might be a 0, in which case, it wouldn't have been swapped with the low's position, had we incremented mid along with high's decrement.

    • @yashjain1492
      @yashjain1492 3 роки тому +3

      Nice👍

    • @whocares7557
      @whocares7557 3 роки тому +2

      @@yashjain1492 Thanks :)

    • @yashjain1492
      @yashjain1492 3 роки тому +1

      In which year you are studying?

    • @whocares7557
      @whocares7557 3 роки тому +1

      @@yashjain1492 Graduated already, working.

    • @yashjain1492
      @yashjain1492 3 роки тому +1

      Then why are you watching these dsa videos?

  • @akrammohammed1167
    @akrammohammed1167 4 роки тому +153

    Can't wait for the next one! Looking forward to a wonderful playlist. This is going to be one of the best playlists ever! Learning so much!

  • @aadeshsharma0001
    @aadeshsharma0001 4 роки тому +39

    bro you are really doing great job.Instead of telling the same dialogue like "improve your dsa" you are actually teaching us, thnakyou so much bro.

  • @sandarbh4358
    @sandarbh4358 4 роки тому +6

    What a coincidence... I stuck in this problem for last half-hour.. and when my notification bell vibes and show this..i think iam the most happiest person in that period of time on this planet.. Thanku bhaiya!!!!

  • @CSSANJAYR
    @CSSANJAYR 2 роки тому +6

    Sir, today i've started working on your SDE sheet and i'm impressed by the way you explain and make things simple .....i have placements coming this year .sure this playlist will help me out there

    • @arh5606
      @arh5606 Рік тому +1

      Could u tell me how did u prepare for placements 😅 Or how did you prioritise between DSA and projects

  • @DIVAKARCCMECH-VelTechChennai
    @DIVAKARCCMECH-VelTechChennai Рік тому +20

    actually i paid 3800 for dsa self paced course. but after seeing yours i never opened that. you really great bhaiya

  • @YashSingh-ir3ec
    @YashSingh-ir3ec 4 роки тому +37

    Keep up the good work. I'll stick to your videos for this wonderful playlist.

  • @yakshitgupta8173
    @yakshitgupta8173 3 роки тому +7

    I have completed my third year, About to enter my 4th year. I just got the news that I have cracked DXC interview. I am very happy .
    I am not very good in DSA. But I want to improve my skills to get much better offers so from today I will start solving your DSA sheet to clear my concepts.
    And from the bottom of my heart I would like to thank you Striver for all your dedication to provide all of us with this gold mine of DSA.
    Also, congrats for your new house. May u keep touching heights brother.

  • @harishbalaji7209
    @harishbalaji7209 4 роки тому +9

    Just loved it 😃 This is the best channel on youtube ,to enhance our CP skills. And making videos amidst office work is much appreciated bro. You're really doing a great job.

    • @omkarshendge5438
      @omkarshendge5438 3 роки тому

      This is not cp this is just basic ds algo.
      Cp is very hard and nobody asks it in interviews

  • @being.popular
    @being.popular 4 роки тому +7

    This series is going to be one of the best leaning series forever. So, it's my humble request that please don't stop until it is completed.
    And
    Thanks for all your efforts!!

  • @shuvbhowmickbestin
    @shuvbhowmickbestin 2 роки тому +4

    Awesome explanation Raj. I left my gfg DSA course to watch your video and I find your free content way better than gfg's paid courses. Massive respect bro, you deserve all the good things happening to you.

  • @sharathnair2790
    @sharathnair2790 4 роки тому +69

    I'm not that good at DSA. But this made me realise i can do it. Thanks brother ❤️

    • @aryanverma7800
      @aryanverma7800 2 роки тому +5

      DSA is about memorization. CP is about pure logical skills

    • @shaniyadav33
      @shaniyadav33 Рік тому +1

      @@aryanverma7800 really aryan??

    • @shaniyadav33
      @shaniyadav33 Рік тому +1

      since i am good at memorising things it will be good for me XD

    • @dharmaraosalana7977
      @dharmaraosalana7977 Рік тому

      @@shaniyadav33 its both

  • @manishsharma2211
    @manishsharma2211 3 роки тому +7

    I have started focusing from today on the campus document list
    Thanks Striver

  • @meshrey
    @meshrey 4 роки тому +133

    Don't have a mentor......
    .
    .
    Don't worry striver here !! 🔥🔥

    • @blank3525
      @blank3525 3 роки тому

      same

    • @karanbhati7552
      @karanbhati7552 3 роки тому

      @Muhammad Elian it wants 12$ to get Access Code

    • @aakashyadav6228
      @aakashyadav6228 3 роки тому +1

      @@karanbhati7552 That's what a scam looks like

  • @mahatrt
    @mahatrt 2 місяці тому

    Superb sir ,I watched many videos about this concept but I don't understand the concept ur explanation is very useful to me✨✨

  • @rishavsharma5000
    @rishavsharma5000 4 роки тому +1

    I love the fact that you took suggestions from the previous comments and adjusted your pace accordingly. You are doing a great job for the community. Hats off to you, brother.

  • @darshantawte7435
    @darshantawte7435 4 роки тому +3

    I think this series is going to be a masterpiece, because he does his research about every solution to a given problem , also it helps to learn about various new algorithms which I never heard off. Thanks a lot for this and hoping you try your best to finishing this series as soon as possible 🔥👍.

  • @yushdecides
    @yushdecides 3 роки тому +1

    Bhai kasam se ye problem tumne sbse acche se smjhaya hua hai.

  • @siddhantjaiswal5999
    @siddhantjaiswal5999 3 роки тому +2

    Bhaiya , ek hi dil hai , kitni baar jeeto ge❤!!
    Blessed to have a mentor like you
    Love from ITER ,BBSR

  • @abhishekranjansingh5348
    @abhishekranjansingh5348 4 роки тому +3

    Bhaiya I firmly waiting for your video on the dutch national algorithm. You taught so nice that it got sticked to my mind in just 1 pass :)
    Thankyou very much !!

  • @rachurirevanth6594
    @rachurirevanth6594 3 роки тому

    Decided Today to prepare for the SDE Sheet, After Procastinating for the very long time, being in the comfort zone, thanks bro for the great content. I make sure that I will learn all these concepts well which no one taught.

  • @its_neel_ok
    @its_neel_ok Рік тому

    I had to sort the array in ascending/decending order in the practicals so i rememberd this 😂--
    int n = nums.size();
    for(int i=0; i

  • @sanakachiranjeevieuro3037
    @sanakachiranjeevieuro3037 3 роки тому

    Bhaiyya did not expected that can do in O(N),O(1) ...but you showed. superb explanation ...keep doing on bhaiyya

  • @shivamehta6537
    @shivamehta6537 3 роки тому +3

    Thank you so much, the second approach was something that I would never be able to think off 🤗

  • @rezaafra187
    @rezaafra187 2 роки тому

    Clarity is mind blowing. You're the BEST.

  • @nikhilsaxena2208
    @nikhilsaxena2208 Рік тому +1

    only youtuber who clearly explain everything......

  • @yogeshpandey730
    @yogeshpandey730 2 роки тому

    Ohh gossh such a wonderful explanation. I had watched 2-3 youtube video but still some doubt in my mind because they haven't explained the graphically now it's clear to me. Tons of thanks striver

  • @yashkumardhawan6961
    @yashkumardhawan6961 3 роки тому

    I simply used map.
    class Solution {
    public:
    void sortColors(vector& nums) {
    map m;
    for(int i=0; i

  • @14Bishal
    @14Bishal 4 роки тому +2

    When striver explains you are bound to comment "understood". Very well explained the algo

  • @nupurgarg2892
    @nupurgarg2892 3 роки тому +1

    Thank you for such a clear explanation. It was my First video of your series and surely i am going to follow all your playlist and will let other's know about this channel too.

  • @rekhasrivastava5114
    @rekhasrivastava5114 2 роки тому

    Wonderful.....
    I was searching for this for long time..
    Trust me..
    You are the best creator on UA-cam.
    Your explanation is superb and fantastic..
    Please please add more such videos...

  • @shubhamgite7730
    @shubhamgite7730 2 роки тому

    bhaya ekdam basic se samz gaya ,superb aap bahot acchse samzate ho thanku thanku so much :)

  • @raushankumargupta7018
    @raushankumargupta7018 3 роки тому +2

    Bss itna kahunga bhaiya pyar ho gya aapse bhaiya kya smjhate h wow..💝

  • @zeenathkatta7480
    @zeenathkatta7480 7 місяців тому

    Excellent explanation. Simple explanation

  • @animeshsharma9932
    @animeshsharma9932 4 роки тому

    Thank you won't be enough. You have no idea how much I respect you brother. Thank you for this. Thank you so much. You are really an inspiration and really helping us. Respect for you. My real guru 🙌🙌🙌🙌🙌

  • @rounakbhushan8571
    @rounakbhushan8571 4 роки тому

    damnn!! You explain things so well bro... Even though I am a working professional and didn't have CSE background, I always go through your videos, and do the problems too. Honestly, each video backs me up with a knowledge that I couldn't have even gained in a couple of months. I think I will be graduate from here with flying colours. I appreciate your enthusiasm and dedication for spreading such a great content. Lots of Love. Thank You Brother.

  • @lincyloisbrian2465
    @lincyloisbrian2465 3 роки тому

    u really make dsa simpler with ur explanation videos...thankyou

    • @freshcontent3729
      @freshcontent3729 3 роки тому

      this is exactly what he wrote, except i used if else instead of switch i wrote the same on leetcode but still not passing can you please find the mistake, it is giving Wrong ans on leetcode
      class Solution {
      public:
      void sortColors(vector& nums) {
      int low=0;
      int mid =0;
      int high = nums.size()-1;
      while(mid

  • @shekharsharma3329
    @shekharsharma3329 3 роки тому

    you are a god level explainer , i dont know how i am understanding that easily from your videos , because iam always confused but you made all this very easy.

  • @shreymehrotra5408
    @shreymehrotra5408 4 роки тому +1

    Understood..crystal clear explanation. Thank you

  • @aniruddharouth
    @aniruddharouth 4 роки тому

    Awesome. Never thought would be able to understand an algorithm under 10mins. Thank you bhaiyya ♥️. Looking forward to complete this entire series along with you.

  • @keertilata20
    @keertilata20 Рік тому

    void Solution::sortColors(vector &A) {
    int low=0;
    int mid=0;
    int high = A.size()-1;

    while(mid

  • @VaishnaviNigam
    @VaishnaviNigam 3 роки тому +4

    great efforts striver.....we guys r so blessed to receive such quality content that too free by uh..thanks a lot

  • @HarshKumar-nh6be
    @HarshKumar-nh6be 4 роки тому +1

    Striver your fan here..)
    I like your videos and they are very useful to me for making my concepts understandable. Please keep uploading these kind of videos..plzz plzz

  • @ayushbahuguna2110
    @ayushbahuguna2110 4 роки тому +1

    That was one of the best explanation. Understood in one go.

  • @kanikagupta2806
    @kanikagupta2806 Рік тому

    this solution is giving TLE. Amother approach.
    class Solution {
    public:
    void sortColors(vector& nums) {

    int last = nums.size()-1;

    for(int i=0,j=0,k=last;j

  • @manishkumarkushwaha1516
    @manishkumarkushwaha1516 2 роки тому

    Understood the problem, beautifully explained.

  • @kapilrana4043
    @kapilrana4043 2 роки тому

    I love the solution striver thank you so much for explaining dutch nation algorithm in a simple manner

  • @yeshwanths7198
    @yeshwanths7198 4 роки тому +3

    You are my inspiration striver,do come up with solutions in python also...

  • @rishalrawat3063
    @rishalrawat3063 4 роки тому +1

    thank you but bro also attach file or document or some blog on algorithm you uses while solving problem , so that if anyone wants to read about that they can quickly click the links on description box . thanks :)

  • @mahesh369944
    @mahesh369944 4 роки тому +1

    Thanks for making videos and selflessly helping others to enhance their skills.👏

  • @vaishiv8466
    @vaishiv8466 Рік тому +1

    You're helping me a lot, thank you so much

  • @anugnagunturu2478
    @anugnagunturu2478 3 роки тому +1

    you are awesome man!!...we are fortunate to have you.

  • @hiteshmalik4802
    @hiteshmalik4802 4 роки тому

    i do understand the way only problem i got is that the key use uses the inbuilt function like vectors and all......... but your explanation is best i do got the point and logic ....

  • @ShreyarkPatiTripathi
    @ShreyarkPatiTripathi Рік тому

    u surely changed the lives of 100s, may god bless u with all his grace..❤❤

  • @aspirant2673
    @aspirant2673 4 роки тому +1

    Great video. Very easy to understand.Hope you will upload videos of this series on a daily basis

  • @raushankumargupta7018
    @raushankumargupta7018 3 роки тому +1

    Bhaiya aaj realise hua ki problem ko krne ka boht way h .... Or iske liy question ko aaps me discuss krna chahiye✅

  • @shubhankarsharma154
    @shubhankarsharma154 4 роки тому +1

    Really easy to understand..... Thank you for the detailed explanation

  • @crustycrabs577
    @crustycrabs577 4 роки тому +2

    Very nice explanation I'm too impressed by the way you interact with us good luck man keep making such amazing videos 🙂🙂🙂👍👍

  • @ashwinsangole9536
    @ashwinsangole9536 Місяць тому

    next level explanation

  • @tangudusaikiran4909
    @tangudusaikiran4909 3 роки тому

    the way u are explaning was really good and helpfull for people like me who dont no what to do next

  • @dharanit3918
    @dharanit3918 4 роки тому +2

    Understood, Thanks a lot! ❤
    Your explanation is easy to grasp the concepts :)

  • @madanmohan5661
    @madanmohan5661 2 роки тому

    Man this is seriously the best approach I think😮🔥

  • @bobbykuhikar5527
    @bobbykuhikar5527 3 роки тому +1

    Excellent explanation & one the best on UA-cam.

  • @shikharai1303
    @shikharai1303 4 роки тому

    sort and informative ..explain the concept smoothly

  • @dinesh.p8642
    @dinesh.p8642 3 роки тому

    Brother, You are helping me alot. I subscribed your channel. Keep the good work. Thanks for giving/sharing your knowledge with community. I am a web developer and machine learning practitioner. I am not that much good in writing optimal solution.

  • @vgovindarajuyadav
    @vgovindarajuyadav 2 роки тому

    For swapping you don't need a temporary variable as nums[mid] ill either be 0 or 2

  • @smitbhatt3647
    @smitbhatt3647 4 роки тому

    instead of creating pointers,we can also do this by creating three variable containing frequencies of 0,1 and 2 this approach uses O(n) TC and SC of three variables. correct me if i am wrong

    • @takeUforward
      @takeUforward  4 роки тому

      that is a two pass approach, it is not cp bro!!

  • @naman120
    @naman120 2 роки тому

    class Solution {
    public:
    void sortColors(vector& nums) {
    int low=0,mid=0,high=nums.size()-1;
    while(mid

  • @ananyaa8597
    @ananyaa8597 2 роки тому

    This question was asked in my Microsoft Interview.Thanks :)

  • @ayushijain2911
    @ayushijain2911 4 роки тому

    Hello Raj,
    Thanks for helping out students and professionals to improve their skills. Yours way of explaining is excellant.

  • @neelabhrabhattacharyya
    @neelabhrabhattacharyya 4 роки тому +2

    Please never stop uploading. We depend on you.

  • @ankitapandey8655
    @ankitapandey8655 3 роки тому

    lovvee the way you explained........ keep teaching........ thankssss for the video.........

  • @arpitmani6553
    @arpitmani6553 3 роки тому

    Thanks man......... really appreciate your work......it helps me a lot and also saves my time.....thanks again

  • @mdsohrabakhtaremam9555
    @mdsohrabakhtaremam9555 2 роки тому

    Quality content as I am a computer science engineering we are not able to grow by own we need strong community who pick up us to become a quality software engineers.

  • @l.paulsonraja4036
    @l.paulsonraja4036 3 роки тому

    You are a great Mentor, Simply Thanks.

  • @tarunsai1560
    @tarunsai1560 4 роки тому +1

    Thanks alot for these placement series bro, I always wished for something like this to help me at this time, My respect to you bro!🤴🏻

  • @piyushjain5658
    @piyushjain5658 4 роки тому

    Best explaination video for this problem on UA-cam!

  • @techtuber1344
    @techtuber1344 Рік тому +1

    Thanks Driver bhai For everything :)❤

  • @sohomdas7642
    @sohomdas7642 4 роки тому

    Bhaiya... your videos are so helpful!!!.... After watching your STL video , I have got a very good grip on it... Also this series provided me with a track on how to proceed with competitive programming!
    Junior from same school.

  • @hsuya3925
    @hsuya3925 4 роки тому +3

    PYTHON SOLUTION:
    class Solution:
    def sortColors(self, nums: List[int]) -> None:
    l=len(nums)
    low=0
    mid=0
    high=len(nums)-1
    while mid

  • @herdreams3893
    @herdreams3893 4 роки тому

    Please keep posting ...Ur Way of describing the algorithm is so easy to understand 💛

  • @sanjusangal
    @sanjusangal 3 роки тому

    Understood by your explanation. Thanks much.

  • @krishjlk
    @krishjlk Рік тому

    Loved it ❤ ... I wish my engineering professor was like you. I would have slept by this time 😊

  • @anshulms002
    @anshulms002 4 роки тому

    thanks !! understood the problem, algorithm and the coding part.. couldn't stop myself from subscribing

  • @binod3204
    @binod3204 3 роки тому

    Thanks for teaching a new algo along with its application.

  • @RahulSharma-bo5jc
    @RahulSharma-bo5jc 3 роки тому +1

    Amazing man. This playlist is Gold! 🙏❤️

  • @NirajKumar-nu4lb
    @NirajKumar-nu4lb 2 роки тому

    your explanation is really awesome....the way you explain with the dry run is much helful

  • @vanshikathakur2093
    @vanshikathakur2093 4 роки тому

    Quite precisely explained.kudos 🙌🙌

  • @entertainment-ji6me
    @entertainment-ji6me 4 роки тому

    pure and best explanation ty so much striver

  • @harpreets1602
    @harpreets1602 4 роки тому +1

    Superb sir, thank you for this series, we will definitely support you as you are supporting us by putiing nice question in brute, better and optimal solution
    Hoping for a lot more videos sir

  • @manubansalcs1003
    @manubansalcs1003 4 роки тому

    Thanks sir
    By you i am learning abc of programs

  • @alesblaze4745
    @alesblaze4745 3 роки тому

    Way you taught make things easy.

  • @asskickerg161
    @asskickerg161 4 роки тому

    Explanation was far better than perfect🙃

  • @ManishMeena-ph2vo
    @ManishMeena-ph2vo 2 роки тому

    solution with three approach ,incredible ! 😍

  • @ayush.kumar_02
    @ayush.kumar_02 4 роки тому +1

    Striver I really like you video... keep it up 🤜🤛

  • @RahulThakur-nj8kk
    @RahulThakur-nj8kk 4 роки тому +1

    Bhai thanks for the video plss make 2-3 question daily if possible

  • @SumitSingh-sb6jn
    @SumitSingh-sb6jn 4 роки тому

    Understood .. your explanations are very very gud...