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

  Рет қаралды 334,820

take U forward

take U forward

Күн бұрын

Пікірлер: 1 000
@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 9 ай бұрын
can u post string series
@utkarshpundeer07
@utkarshpundeer07 22 күн бұрын
Understood 👍 You are a legend sir
@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 😂😂🙏🙏🙏🙏
@ashutoshkr99
@ashutoshkr99 Жыл бұрын
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 7 ай бұрын
same thoughts!
@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
@coolestCatEver
@coolestCatEver 3 ай бұрын
@@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)
@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
@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
@crazybro4383
@crazybro4383 8 ай бұрын
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 Жыл бұрын
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.
@bgovindnaren7405
@bgovindnaren7405 Жыл бұрын
bhai yaar kya hi video banaya yr... even paid courses dont explain concepts with this much depth... thanks!!!
@PrasunKBasak
@PrasunKBasak Жыл бұрын
This guy is putting so much efforts for us. Thanks striver.
@manasranjan7894
@manasranjan7894 Жыл бұрын
Thanks striver
@yasaswinikarumuri9590
@yasaswinikarumuri9590 8 ай бұрын
mind blowing. Understood DNF algo clearly for the first time. Thanks Striver!
@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. ❤❤
@adityaghosh6170
@adityaghosh6170 4 ай бұрын
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.
@mayanksaurabhmayanksaurabh9271
@mayanksaurabhmayanksaurabh9271 Жыл бұрын
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.
@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!
@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 5 ай бұрын
how are the placements there after mtech?
@not_your_Tridiiib
@not_your_Tridiiib Ай бұрын
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❤❤❤❤❤
@ziggywiggys
@ziggywiggys 7 ай бұрын
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
@shantanughosh655
@shantanughosh655 12 күн бұрын
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
@myamazonproducts1683
@myamazonproducts1683 Жыл бұрын
Even the paid courses wouldn't teach this depth. I'm following your course sheet @take U forward You are the best.
@PrinceYadav-ll8hs
@PrinceYadav-ll8hs Жыл бұрын
Best explanation i have ever seen for this dutch algorithm ❤
@MusaafirSonu
@MusaafirSonu 3 ай бұрын
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...❤
@kushagramishra5638
@kushagramishra5638 Жыл бұрын
understood😌,the optimal approach explanation was mind blowing.
@immortalized_onion
@immortalized_onion 5 ай бұрын
This is pretty easily the best explanation of the algorithm on YT imo.
@suyashshinde2971
@suyashshinde2971 Жыл бұрын
SDE Sheet Day 1 Problem 5 Done!
@frestree890
@frestree890 11 ай бұрын
For the first time, I ever understood Dutch Algo. Thanks for you efforts❤
@LohithaRepalle
@LohithaRepalle Жыл бұрын
Your effort into each video was incredible, and I am so glad to have found your course Thank you, Raj❤
@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
@samreenimam8608
@samreenimam8608 10 ай бұрын
Thank you so much Striver.. now I'm able to visualize the increments and decrements...amazingly solved!!
@syeedtalha1550
@syeedtalha1550 Жыл бұрын
Hey everyone, welcome back to the channel, I hope you guys are doing extremely well.... this is my favorite dialogue 😅😅😅😅😅
@krishnakarule3708
@krishnakarule3708 5 ай бұрын
I cant believe how someone can teach these for free of cost
@tech_wizard9315
@tech_wizard9315 Жыл бұрын
Have you uploaded entire explanation of DP, from scratch to advance level?
@takeUforward
@takeUforward Жыл бұрын
Dude yes!
@rohansachdeva627
@rohansachdeva627 11 ай бұрын
Gold Content. Direct into brain. UNDERSTOOD
@suheabkhan2546
@suheabkhan2546 Жыл бұрын
Understood
@takeUforward
@takeUforward Жыл бұрын
dekh th lo bhai
@jashhinger442
@jashhinger442 Жыл бұрын
😂😂
@suheabkhan2546
@suheabkhan2546 Жыл бұрын
Fast forward karke dekhliya ...
@vigneshreddy7936
@vigneshreddy7936 19 күн бұрын
His explanation is Outstanding ,but the guy who wrote this algorithm deserve a applauds
@sameer_701
@sameer_701 Жыл бұрын
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
@Rudraksx
@Rudraksx 4 ай бұрын
Such crisp explanation with such simplicity, mind boggling!
@Mythri333
@Mythri333 Ай бұрын
No lag..direct to the point❤. THANK YOU SO MUCH.😊
@senpaidawwwggg
@senpaidawwwggg Жыл бұрын
Implemented the code using a[high] and it got executed correctly, thanks!❤
@kiranshinde03
@kiranshinde03 Жыл бұрын
yaar just awesome 😍 as like you said, nowhere on KZbin, the explanation like you is taught..Yes, it's true 💯
@subhamagarwal476
@subhamagarwal476 8 ай бұрын
never seen such an amazing explanation to this problem. Thank you striver
@utkarshpant5297
@utkarshpant5297 Жыл бұрын
This is by far the best explanation of this algorithm I've seen anywhere.
@messiisthebest
@messiisthebest 7 ай бұрын
just wanna say, i am imagining like a pro after learning this algorithm
@saisanjan5398
@saisanjan5398 Ай бұрын
Big fan of his teaching style. Too good. Best DSA Course in the world
@jeet-smokey
@jeet-smokey 9 ай бұрын
Seedhi baat.....no bakwas.....Kudos to your efforts Striver.
@Srinivasssssss
@Srinivasssssss 11 ай бұрын
Next Level Explaination...! Thank you so much..❤❤❤
@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.❤
@the.harisankar
@the.harisankar 18 күн бұрын
if i had an option to like this video 1000 times, I would do it. Thank you, broo!! such a nice explanation.
@shayo76
@shayo76 10 ай бұрын
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
@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!!!!
@benzemabercelio4918
@benzemabercelio4918 Жыл бұрын
Not until I came to the comment, I noticed that the video length was 25mints, out of which not a single minute was wasted, we understood at least something at every minute so thank you for making us understand the DNF at O(n) time, brother, you definitely earned a sub
@krishnagavas6163
@krishnagavas6163 9 ай бұрын
What a beautiful algorithm, and beautifully explained. Kudos to you Striver.
@sarangkumarsingh7901
@sarangkumarsingh7901 8 ай бұрын
There can't exist a better explanation than this for DNF 😊❤
@kirandahake6770
@kirandahake6770 7 ай бұрын
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 🥳🥳🥳🥳
@rohitchanda8461
@rohitchanda8461 10 ай бұрын
What an explanation! This guy is spot on every time! I could visualize the sorting so clearly and easily!
@learner3206
@learner3206 8 ай бұрын
The update of your website :) mind blowing sir!
@rajeshseptember09
@rajeshseptember09 Жыл бұрын
Great video Raj. But I have found an alternative solution with same time and space complexity (submission was fine on leetcode). Explanation: 1. I make a first iteration/pass over the nums array and I store the count of red, white and blue color in a separate array of length 3 (similar space constraint of using 3 pointers). 2. Then I make another pass over the nums array to mark the first set of elements as 0, second set of elements as 1 and the third set of elements as 2. var sortColors = function(nums) { let arr = new Array(3).fill(0); for(let i = 0; i
@hardikksharmaaa
@hardikksharmaaa Жыл бұрын
Time complexity is still O(2N). Use his approach to make it O(N)
@KeerthanaPatnana
@KeerthanaPatnana Жыл бұрын
Started your DSA course.Thoroughly enjoying your course from the start.Thank you for helping us😊
@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.
@vidhiarora4995
@vidhiarora4995 2 ай бұрын
whatta optimal approach.....my mind really blew away!!!!
@iwd2405
@iwd2405 Жыл бұрын
Best Place to learn. No Comparison To This Channel. Thank you Striver Bhaiya for such a content
@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.
@CHJOHN-m9p
@CHJOHN-m9p 5 ай бұрын
the optimal method really mind blowing . after watching video for 25 min the optimal code feels like easy one. His dedication levels 🙌
@mr_noob6361
@mr_noob6361 Жыл бұрын
Arey sir🙏🙏🙏🙏🤐🤐🤐i am speechless ....just one thing i want to say.#God of DSA
@shweta8677
@shweta8677 3 ай бұрын
Just Wow!! No words can explain how knowledgable this guy is !!🤩🙌
@sumankumardas9685
@sumankumardas9685 Жыл бұрын
Best DNF Explanation ever !!!!
@rajatshukla2605
@rajatshukla2605 2 ай бұрын
Understood! Elegantly explained!
@notmrabhi1
@notmrabhi1 Жыл бұрын
Ohh God, the Dutch national flag Algo is really lit, and as u said it really blew my mind.
@arunsagarsa3613
@arunsagarsa3613 10 ай бұрын
literally a hero material.
@RohitSingh-sb3sw
@RohitSingh-sb3sw Жыл бұрын
Wonderfully explained the Algorithm ! DSA God The Striver Much Love Man !
@twinklelight9829
@twinklelight9829 Жыл бұрын
thankyou soooo much striver..u are helping me alot..if i ever succeed i my career(getting a good job) then you will be the first reason!!!!
@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.
@Pravenkumar.D
@Pravenkumar.D 4 ай бұрын
Crystal clear explanation in each and every step ......Awesome DSA course i had ever seen🔥🔥
@rangedarcher2041
@rangedarcher2041 Ай бұрын
One of the best explanations to the approach so far...Fantastic
@ankitamishra7510
@ankitamishra7510 8 ай бұрын
As you said ... My mind blowed when I understood the optimal approach ie. Dutch National Flag Algorithm.... Hatts off to you ..just because of you I get up everyday to code Love you striver ❤❤
@NitishGautam-g1j
@NitishGautam-g1j Ай бұрын
Love you bro , you are GOAT ...Everyone who has studied from you always have immense respect in you . Thankyou so much for your selfless contribution to the tech society
@hariomjha189
@hariomjha189 7 ай бұрын
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😍
@itzmartin20
@itzmartin20 Жыл бұрын
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!
@yashsharma6112
@yashsharma6112 7 ай бұрын
Best DNF algo explanation I have found.
@eshaalakshmids
@eshaalakshmids 4 ай бұрын
Absolutely brilliant explanation. You are making one fall in love with coding. Thank you for all your efforts. We are so grateful to u.
@ayushkumarlavania7046
@ayushkumarlavania7046 10 ай бұрын
understood, the thought process is taking O(1) space in brain results in fast retrival too. Thanks bhaiya.
@shra1
@shra1 Жыл бұрын
It was fun understanding it that too at midnight 1:00 AM (not even feeling sleepy)
@Sarjais_Raja
@Sarjais_Raja 5 ай бұрын
This is the best DSA course in the market ♥♥
@yogeshedekar6078
@yogeshedekar6078 Жыл бұрын
Easily the best solution with intuition for the Dutch Flag problem. The algorithm in itself is a little bit tricky to understand but this crisp solution heps to inderstand it so well.
@gauravchhimpa8510
@gauravchhimpa8510 10 ай бұрын
Understood . Love from Haryana. ❤❤❤❤
@balakrishna6240
@balakrishna6240 2 ай бұрын
DNF algorithm thought process explanation is really awesome, worth content , superb explanation sir
@sonalisingh7932
@sonalisingh7932 Ай бұрын
Amazing content. Understood the concept very welll.
@mohammadfarhansadik169
@mohammadfarhansadik169 Жыл бұрын
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
@shadowslayer2248
@shadowslayer2248 6 ай бұрын
Understood. Best explanation ever!! Intuition and Logic explanation was so smooth and easy to grasp I was able to code it in one go even before seeing the actual code!!! No amount of thanks can cover for this. Please make A2Z String videos too and we'll be really really grateful 🙏🙏🙏🙏
@chetanpatil9917
@chetanpatil9917 3 ай бұрын
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
@ManishKumar-d9b3j
@ManishKumar-d9b3j 2 ай бұрын
The dutch national flag algorithum is very straight to the point i am able to understand line by line great explanation raj ....
@snehashisratna9074
@snehashisratna9074 Жыл бұрын
i'm in love with ur teaching style ........
@susmitha5g627
@susmitha5g627 2 ай бұрын
You blow my mind by making everything look so simple!!
@kunalkumarmaurya7253
@kunalkumarmaurya7253 3 ай бұрын
I have never visualize your any content the way I visualize this, awesome!! ❤❤❤❤
@ChandrahasaMutyala
@ChandrahasaMutyala Жыл бұрын
Jumped from striver sheet to YT just to subscribe. kudos to your work mate.
@sainaid
@sainaid 9 ай бұрын
You are a Gem! your way of explaining different approaches is easy to understand. Thank you for providing such a valuable content for free. ❤
@chandanramteke3878
@chandanramteke3878 5 ай бұрын
best explanation ever watched.
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 4,7 МЛН
За кого болели?😂
00:18
МЯТНАЯ ФАНТА
Рет қаралды 3,2 МЛН
Муж внезапно вернулся домой @Oscar_elteacher
00:43
История одного вокалиста
Рет қаралды 7 МЛН
L7. Sort a LinkedList of 0's, 1's and 2's | Multiple Approaches
23:23
take U forward
Рет қаралды 80 М.
This Algorithm is 1,606,240% FASTER
13:31
ThePrimeagen
Рет қаралды 853 М.
Next Permutation - Intuition in Detail 🔥 | Brute to Optimal
28:15
take U forward
Рет қаралды 460 М.
Sort an Array of 0s, 1s & 2s | DNF Sorting Algorithm | Leetcode 75
33:39
Kadane's Algorithm | Maximum Subarray Sum | Finding and Printing
20:09
take U forward
Рет қаралды 491 М.
Big-O Notation - For Coding Interviews
20:38
NeetCode
Рет қаралды 518 М.
Dutch National Flag Algorithm. Explained with playing cards.
12:11
Count Inversions in an Array | Brute and Optimal
24:17
take U forward
Рет қаралды 242 М.
Sort Colors - Quicksort Partition - Leetcode 75 - Python
15:48
А я думаю что за звук такой знакомый? 😂😂😂
00:15
Денис Кукояка
Рет қаралды 4,7 МЛН