No video

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

  Рет қаралды 254,463

take U forward

take U forward

Күн бұрын

Notes/C++/Java/Python codes: takeuforward.org/data-structu...
Problem link: bit.ly/3CsgYAa
We have solved the problem, and we have gone from brute force and ended with the most optimal solution.
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
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

Пікірлер: 855
@takeUforward
@takeUforward Жыл бұрын
Let's march ahead, and create an unmatchable DSA course! ❤ Use the problem links in the description.
@harshavardhan184
@harshavardhan184 Жыл бұрын
This is the consistency we need from you bhai ❤️!
@goldiladani6579
@goldiladani6579 5 ай бұрын
can u post string series
@apoorvchaudhary2592
@apoorvchaudhary2592 Жыл бұрын
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
@takeUforward
@takeUforward Жыл бұрын
the first 30 seconds though promotion of our course XD
@shubhamkhose7474
@shubhamkhose7474 Жыл бұрын
​@@takeUforward 😂😂
@navkaransingh3948
@navkaransingh3948 Жыл бұрын
​@@takeUforward 😂😂😂😅
@rohanraj2604
@rohanraj2604 Жыл бұрын
@@takeUforward 😆😆
@sauravbiswajit8091
@sauravbiswajit8091 Жыл бұрын
​@@takeUforward😂
@ashishdhal4614
@ashishdhal4614 Жыл бұрын
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.
@tanishpahwa4779
@tanishpahwa4779 Жыл бұрын
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.
@prashanthvaidya
@prashanthvaidya Жыл бұрын
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 Жыл бұрын
You learn, and you grow every day :)
@sauravbiswajit8091
@sauravbiswajit8091 Жыл бұрын
Btw who is Raj ...He is our Striver Bhaiya ....The one and only piece 😂😂🙏🙏🙏🙏
@brajeshmohanty2558
@brajeshmohanty2558 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
@@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 Жыл бұрын
@@lambslife1802 at the same place....is fits the condition....take such examples and solve... you will get it
@ashutoshkr99
@ashutoshkr99 9 ай бұрын
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 3 ай бұрын
same thoughts!
@066_varshamalyan9
@066_varshamalyan9 Жыл бұрын
This video clarified my concepts about this algorithm much better than I had before. Thank you so much for delivering the best quality knowledge. ❤❤
@bgovindnaren7405
@bgovindnaren7405 9 ай бұрын
bhai yaar kya hi video banaya yr... even paid courses dont explain concepts with this much depth... thanks!!!
@md.ualiurrahmanrahat2400
@md.ualiurrahmanrahat2400 11 ай бұрын
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.
@mayanksaurabhmayanksaurabh9271
@mayanksaurabhmayanksaurabh9271 10 ай бұрын
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.
@yasaswinikarumuri9590
@yasaswinikarumuri9590 4 ай бұрын
mind blowing. Understood DNF algo clearly for the first time. Thanks Striver!
@ziggywiggys
@ziggywiggys 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
@DevashishJose
@DevashishJose Жыл бұрын
Understood, Kudos to you striver ,once you told the pseudo code I did dry run on my own and understood it completely, thanks for explaining so beautifully
@SelvaArumugam-xq5mf
@SelvaArumugam-xq5mf Жыл бұрын
Understood it in a very clear manner bruh. It's the way you are explaining it makes isa very easy. I guess I will never forget this also.
@PrasunKBasak
@PrasunKBasak Жыл бұрын
This guy is putting so much efforts for us. Thanks striver.
@manasranjan7894
@manasranjan7894 Жыл бұрын
Thanks striver
@krishnakarule3708
@krishnakarule3708 Ай бұрын
I cant believe how someone can teach these for free of cost
@rohitchanda8461
@rohitchanda8461 6 ай бұрын
What an explanation! This guy is spot on every time! I could visualize the sorting so clearly and easily!
@manipandit18
@manipandit18 Жыл бұрын
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
@krishnaemani5924
@krishnaemani5924 Жыл бұрын
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.
@KeerthanaPatnana
@KeerthanaPatnana 10 ай бұрын
Started your DSA course.Thoroughly enjoying your course from the start.Thank you for helping us😊
@cinime
@cinime Жыл бұрын
Understood! Super wonderful explanation as always, thank you very very much for your effort!
@itzmartin20
@itzmartin20 11 ай бұрын
Thanks a billion for your utmost explaination and dedication, the intuition was something that I've never knew before and it was indeed blow my mind. Thank you Striver! Understood!
@t6hp
@t6hp Жыл бұрын
Man, I love everything you're doing! Salut from Egypt! You're definitely helping poor people with ambition from all over the world!
@krishnagavas6163
@krishnagavas6163 6 ай бұрын
What a beautiful algorithm, and beautifully explained. Kudos to you Striver.
@samreenimam8608
@samreenimam8608 6 ай бұрын
Thank you so much Striver.. now I'm able to visualize the increments and decrements...amazingly solved!!
@utkarshpant5297
@utkarshpant5297 11 ай бұрын
This is by far the best explanation of this algorithm I've seen anywhere.
@digvijaysingh2709
@digvijaysingh2709 Жыл бұрын
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
@user-cd7tv9zh2u
@user-cd7tv9zh2u Жыл бұрын
Your effort into each video was incredible, and I am so glad to have found your course Thank you, Raj❤
@kiranshinde03
@kiranshinde03 Жыл бұрын
yaar just awesome 😍 as like you said, nowhere on KZbin, the explanation like you is taught..Yes, it's true 💯
@ShawonGhoshdastidar
@ShawonGhoshdastidar Жыл бұрын
Thanks a lot sir for explaining the algorithm in detail. Understood every single bit.
@prateekrohilla1
@prateekrohilla1 Жыл бұрын
greatest explanation .. I've ever watched for this question ... you made it super simple
@frestree890
@frestree890 7 ай бұрын
For the first time, I ever understood Dutch Algo. Thanks for you efforts❤
@MusaafirSonu
@MusaafirSonu 2 күн бұрын
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...❤
@crazybro4383
@crazybro4383 4 ай бұрын
Sirf diagram se pura algorithm khud hi samajh aa gya, you are an amazing teacher. Thank you for providing such great content for free.
@adityaghosh6170
@adityaghosh6170 11 күн бұрын
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.
@kushagramishra5638
@kushagramishra5638 Жыл бұрын
understood😌,the optimal approach explanation was mind blowing.
@jeet-smokey
@jeet-smokey 5 ай бұрын
Seedhi baat.....no bakwas.....Kudos to your efforts Striver.
@subhamagarwal476
@subhamagarwal476 4 ай бұрын
never seen such an amazing explanation to this problem. Thank you striver
@PHANTOMWORLD
@PHANTOMWORLD Жыл бұрын
I have seen the one pass algorithm before but this time I get to know the intuition. Thanks bhaiya this if f****** amazing.❤
@khushikoshta954
@khushikoshta954 11 ай бұрын
Extremely well explained! UNDERSTOOD :)
@myamazonproducts1683
@myamazonproducts1683 Жыл бұрын
Even the paid courses wouldn't teach this depth. I'm following your course sheet @take U forward You are the best.
@senpaidawwwggg
@senpaidawwwggg Жыл бұрын
Implemented the code using a[high] and it got executed correctly, thanks!❤
@1tav0
@1tav0 11 ай бұрын
Awesome like always. i have gained all of my dsa knowledge from this channel i am forever grateful to you sir.
@expirytrader5802
@expirytrader5802 Жыл бұрын
What work you are doing, I'm almost 10 years old in IT(qe automation). This learning experience is so great to me.
@code_of_chords
@code_of_chords 20 күн бұрын
Such crisp explanation with such simplicity, mind boggling!
@PrinceYadav-ll8hs
@PrinceYadav-ll8hs Жыл бұрын
Best explanation i have ever seen for this dutch algorithm ❤
@user-rc2dt4kz7k
@user-rc2dt4kz7k 7 ай бұрын
Striver Bhaiya, Your DSA tutorials are fantastic! Love the depth and simplicity in your explanations. Really helping me grasp these concepts easily. Thank you!
@Srinivasssssss
@Srinivasssssss 7 ай бұрын
Next Level Explaination...! Thank you so much..❤❤❤
@sainaid
@sainaid 5 ай бұрын
You are a Gem! your way of explaining different approaches is easy to understand. Thank you for providing such a valuable content for free. ❤
@shayo76
@shayo76 6 ай бұрын
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
@subasishmula
@subasishmula Жыл бұрын
very good explanation, this explanation no one discussed in their video., great
@mohammadfarhansadik169
@mohammadfarhansadik169 11 ай бұрын
You are best instructor. Sometime I feel diffucult to understand but after watching 2nd time it becomes easy and you have an exellent skill of explanation
@devanshaggarwal23
@devanshaggarwal23 Ай бұрын
Excellent explanation of each and every question with concept clarity. Wish I could have found this earlier!
@stillness-in-motion
@stillness-in-motion 7 ай бұрын
What is teaching and explanations skils you have striver. Awesome Man and thanks for making these videos.
@aayushranjan3675
@aayushranjan3675 Жыл бұрын
Amazing algorithm complemented by an even better explanation!!!
@user-hy8gv8dy8y
@user-hy8gv8dy8y 8 күн бұрын
Crystal clear explanation in each and every step ......Awesome DSA course i had ever seen🔥🔥
@kundank11
@kundank11 4 ай бұрын
Understood bahot achhe se, maza aa gya bhai :)
@shra1
@shra1 Жыл бұрын
It was fun understanding it that too at midnight 1:00 AM (not even feeling sleepy)
@heybuddy_JAI_SHREE_RAM
@heybuddy_JAI_SHREE_RAM Жыл бұрын
I love your videos and your code helps a lot in understanding.
@AjayKumar-sx6qo
@AjayKumar-sx6qo 11 ай бұрын
This is the best explanation for this problem I have come across.
@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!!!!
@AbhishekKumar-cv1dh
@AbhishekKumar-cv1dh Жыл бұрын
Understood and loved it!! 🔥
@manishkarmakar3927
@manishkarmakar3927 Жыл бұрын
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 Ай бұрын
how are the placements there after mtech?
@eshaalakshmids
@eshaalakshmids Ай бұрын
Absolutely brilliant explanation. You are making one fall in love with coding. Thank you for all your efforts. We are so grateful to u.
@suyashpurwar631
@suyashpurwar631 Жыл бұрын
I'm feeling very great that I had came quite close to coming up with the optimal solution myself.
@immortalized_onion
@immortalized_onion Ай бұрын
This is pretty easily the best explanation of the algorithm on YT imo.
@sunilkamat8199
@sunilkamat8199 Жыл бұрын
Great bhaiya.. Its crystal clear😊 Thanks for the intuition
@Oldmonk3321
@Oldmonk3321 4 ай бұрын
Mine mind is blown ❤️ so nicely explained the purpose of each pointers
@ChandrahasaMutyala
@ChandrahasaMutyala Жыл бұрын
Jumped from striver sheet to YT just to subscribe. kudos to your work mate.
@learner3206
@learner3206 4 ай бұрын
The update of your website :) mind blowing sir!
@rohansachdeva627
@rohansachdeva627 7 ай бұрын
Gold Content. Direct into brain. UNDERSTOOD
@hariomjha189
@hariomjha189 3 ай бұрын
very indepth with clear concepts, you are doing something which is much needed for average students for taking them litreally forward. keep shining sir, mahadev is always with you . lots of love from bihar😍
@konankikeerthi
@konankikeerthi 2 ай бұрын
Thanks for your great efforts bro. Never heard such a crystal clear explanation. grateful to find this channel. Understood clearly. Once again thank you soo much
@priyotoshsahaThePowerOf23
@priyotoshsahaThePowerOf23 Жыл бұрын
Heavily understood ..sir it's soo easy can remember for long time😍
@user-hx2zj3ew7o
@user-hx2zj3ew7o Ай бұрын
the optimal method really mind blowing . after watching video for 25 min the optimal code feels like easy one. His dedication levels 🙌
@impalash_ag
@impalash_ag 2 ай бұрын
hi @takeUforward, understood. Your efforts are totally worth it. You're doing a great job man!
@ayushbhagat9817
@ayushbhagat9817 6 ай бұрын
Thanks for the intuition, really great video!!
@ishasingh6726
@ishasingh6726 Жыл бұрын
Thank you striverr ,i understood the optimal solution 💙💫
@notmrabhi1
@notmrabhi1 Жыл бұрын
Ohh God, the Dutch national flag Algo is really lit, and as u said it really blew my mind.
@rahuljmd
@rahuljmd Жыл бұрын
Understood extremely well, thanks for the explanation..
@shravanichavan1854
@shravanichavan1854 11 ай бұрын
understood !!! your teaching method is superb .
@muskangupta5873
@muskangupta5873 7 ай бұрын
great explanation...love it..thanks a ton
@GauravMishra-fj8pp
@GauravMishra-fj8pp Ай бұрын
Solid explanation. Good job Striver!
@swapnilhajare5557
@swapnilhajare5557 Жыл бұрын
Amazing understood completely 👍🏻
@ishhh_k
@ishhh_k 6 ай бұрын
I have never ever commented on any video, but this... this was truly out of the world.. I started this video at 1.30 am half tired half asleep.. by the time you finished explaining the DNF algo, I was mind blown, fascinated and wide awake lol.. THANKS A LOT FOR THIS STRIVER.. Your efforts are truly priceless.. No money can ever compensate for this level of teachings.. THANKS ! 🤍
@user-cx4mh7sc2j
@user-cx4mh7sc2j Ай бұрын
For every problem only after watching your video it gets into my head directly striver. Thank you so much really for this unconditional support to us without you i cannot even imagine how my problem solving skills would be and also i am not satisfied watching other youtubers video because after watching yours i just simply search for you. Very very thanks to you bhaiya.
@jayashree_714
@jayashree_714 7 ай бұрын
thank you for making everything in a understandable manner 😊😊
@ankitsrivastava2994
@ankitsrivastava2994 9 ай бұрын
Really commendable .. Keep going... Tons of thanks
@aryanmaniyar3475
@aryanmaniyar3475 Жыл бұрын
Amazing video Bhaiya! Ye logic hi to chahiye tha 😊
@torishi82
@torishi82 27 күн бұрын
Brillian bhai. Thank you.
@kajalmukherjee3944
@kajalmukherjee3944 Жыл бұрын
Just unbelievable consistency 🔥❤️
@bharanichandraprabhu267
@bharanichandraprabhu267 Жыл бұрын
The dedication you put for the us is very high when compared to the dedication we put for ourselves!!thank you so much
@Kaurs_Life
@Kaurs_Life Жыл бұрын
Such an easy go explanation!! Thanku so much
@VallapuneniLakshmanarao
@VallapuneniLakshmanarao Жыл бұрын
ur explanition was lovely broo i just loved it the way u explained
@KrishnaSagar02
@KrishnaSagar02 8 ай бұрын
Wow! Understood very well.
@sarangkumarsingh7901
@sarangkumarsingh7901 4 ай бұрын
There can't exist a better explanation than this for DNF 😊❤
@xrishabh
@xrishabh 2 ай бұрын
Perfect explanation of this algorithm. As easy as it can get.
@svm1512
@svm1512 Ай бұрын
Understood and It was mind blowing 🙌
@samuelfrank1369
@samuelfrank1369 9 ай бұрын
Understood. Thanks a lot . Make more videos soon please.
Coding Interviews Be Like
5:31
Nicholas T.
Рет қаралды 6 МЛН
这是王子儿子吗
00:27
落魄的王子
Рет қаралды 20 МЛН
لااا! هذه البرتقالة مزعجة جدًا #قصير
00:15
One More Arabic
Рет қаралды 24 МЛН
Launching the best DSA Course + Platform
36:29
take U forward
Рет қаралды 85 М.
Why UK 🇬🇧 is going Bankrupt? : Detailed Economic Case Study
20:37
10 Math Concepts for Programmers
9:32
Fireship
Рет қаралды 1,8 МЛН
My Brain after 569 Leetcode Problems
7:50
NeetCode
Рет қаралды 2,5 МЛН
Kadane's Algorithm | Maximum Subarray Sum | Finding and Printing
20:09
take U forward
Рет қаралды 366 М.
Google Coding Interview With A High School Student
57:24
Clément Mihailescu
Рет қаралды 4,1 МЛН
3 Sum | Brute -  Better - Optimal with Codes
38:25
take U forward
Рет қаралды 271 М.
Please Master These 10 Python Functions…
22:17
Tech With Tim
Рет қаралды 115 М.
这是王子儿子吗
00:27
落魄的王子
Рет қаралды 20 МЛН