Set Matrix Zeroes | O(1) Space Approach | Brute - Better - Optimal

  Рет қаралды 320,662

take U forward

take U forward

Күн бұрын

Problem Link: bit.ly/3CukQke
Notes/C++/Java/Python codes: takeuforward.org/data-structu...
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
00:40: Problem statement
01:49: Brute-force solution
05:13: - Code
06:28: - Complexity
07:10: Better solution
12:16: - Code
13:49: - Complexity
14:17: Optimal solution
23:24: - Code
29:02: - Complexity

Пікірлер: 462
@takeUforward
@takeUforward 11 ай бұрын
Please watch our new video on the same topic: kzbin.info/www/bejne/hGGwmH-smMqLba8
@SujitKUmar-gy5xr
@SujitKUmar-gy5xr Ай бұрын
bhaiya same hi to dono hai
@saisree04
@saisree04 3 ай бұрын
Mind got blown away after listening to the optimal solution
@ranjani7896
@ranjani7896 3 ай бұрын
😂😂
@aaryakapoor8352
@aaryakapoor8352 21 күн бұрын
mind got blown with the optimal approach
@dpxy1599
@dpxy1599 9 ай бұрын
This optimal approach is confusing.
@KaifKhan-sb2yr
@KaifKhan-sb2yr 3 ай бұрын
Watch again easy it is 😊
@takeUforward
@takeUforward Жыл бұрын
Let's march ahead, and create an unmatchable DSA course! ❤ Use the problem links in the description.
@suyashpurwar631
@suyashpurwar631 11 ай бұрын
I was able to do the second approach by myself and I'm feeling really good about it!
@RohanKumar-gy4gl
@RohanKumar-gy4gl 10 ай бұрын
HOLY S... bruh is an einstein for sure
@adityamadhav1509
@adityamadhav1509 25 күн бұрын
its not a big deal though, but it really ensures that u r growing as a coder ,keep it up bruh.regarding second approach i though that instead of using two arrays row and column,we can just use one array of pair type where each element of the array is a pair whose first element is ,arked row and second elemen is marked column.
@Carson00_11
@Carson00_11 19 күн бұрын
i am the only dumb then because i cant do anything
@jacobblack2544
@jacobblack2544 17 күн бұрын
@@Carson00_11 yes XD
@AkshanshLohan
@AkshanshLohan 3 күн бұрын
@@Carson00_11never say something negative about yourself even as a joke
@CodeBoost8375
@CodeBoost8375 Жыл бұрын
Understood! Very well 🔥🔥🔥. And half a hour to example every step from intuition ---> approach till code it shows how you work hard to provide such wonderful video's thanks a lot for this efforts brother.
@jatinsharma1595
@jatinsharma1595 7 ай бұрын
Understood. Happy that I came up with the better approach by myself, seriously blown away by the optimal approach. Thank you so much Striver
@saisree04
@saisree04 3 ай бұрын
mind got blown away after listening to the optimal solution
@Manishgupta200
@Manishgupta200 Жыл бұрын
Really amazing Striver. In-place space optimisation method is really out of my imagination. you make everyting real in very much optimal way. Thankyou Striver for such an amazing tutorial ❤
@yugal8627
@yugal8627 Жыл бұрын
OMG , I had watched many tutorials for this problem but never understood it clearly . Thankyou very much for your step-by-step detailed explanation , looking for more content from you in future🙂
@vivekdalal1724
@vivekdalal1724 Жыл бұрын
this is the only study related playlist which im binging by choice and loving it
@unknown_fact1586
@unknown_fact1586 3 күн бұрын
After following your videos, I'm able to understand the problems on my own and even come up with optimal solutions myself. Thanks for the amazing videos.
@cinime
@cinime Жыл бұрын
Understood! Amazing explanation as always, thank you very much for your effort!!
@devanshulpratapsingh5963
@devanshulpratapsingh5963 Жыл бұрын
So desperately trying this question for 2 days wasn’t able to optimise it, Now I can❤🔥
@shubhamagarwal1434
@shubhamagarwal1434 2 күн бұрын
#Free Education For All.. # Bhishma Pitamah of DSA...You could have earned in lacs by putting it as paid couses on udamey or any other elaerning portals, but you decided to make it free...it requires a greate sacrifice and a feeling of giving back to community, there might be very few peope in world who does this...."विद्या का दान ही सर्वोत्तम दान होता है" Hats Off to you man, Salute from 10+ yrs exp guy from BLR, India.....
@dxan
@dxan 4 ай бұрын
Your teaching skills are very well and I must say they are on another level. Thank you so much for the content.
@jaydeepkarena
@jaydeepkarena Жыл бұрын
Great explanation Raj. Thanks for creating this videos. Keep making videos like this. I have just started your SDE sheet for learning DSA
@Atharva_kathiyawadi
@Atharva_kathiyawadi Жыл бұрын
along with i really learn how to write clean code & improve readability !! thanks striver
@josephwilliams9
@josephwilliams9 9 ай бұрын
Code from older video is better. Also I understood the intuition in this video's explanation by understanding it from older video. A request - PLEASE DON'T DELETE OLDER VIDEOS EVER, THEY TOO ARE GEM ❤
@kamalakannanng4206
@kamalakannanng4206 6 ай бұрын
Can you please share the older video link ?
@krishsachdeva1105
@krishsachdeva1105 Жыл бұрын
Bhaiya abhi shayad itne views nhi aarhe but rojj video daalte raho iss course ko complete karna and this will smash all education viewing records. Salute++
@rishijain9081
@rishijain9081 4 күн бұрын
What an explaination man !! Optimal solution was really out of my imagination.
@hari7110
@hari7110 6 ай бұрын
super bro, i got 1st approach and was scratching my head to optimize it , watched last method twice now i understood🤩
@AbhishekSingh-mh2fg
@AbhishekSingh-mh2fg 11 ай бұрын
Recently started learning DSA, i was able to come up with the same approach as 1st and 2nd, even though I couldn't complete it but I'm happy I came with some approaches. Thanks for this great explanation.
@anushkachavan5065
@anushkachavan5065 3 ай бұрын
You are my motivation to solve the dsa problems every day. Thanks for providing these videos, it helps a lot🔥
@hashcodez757
@hashcodez757 2 ай бұрын
great brother!! just can't imagine the optimizations you made hats off sirr!!
@NikitaSingh-kz2ii
@NikitaSingh-kz2ii Жыл бұрын
watched the video thrice to finally get optimal approach to my head. thankyou for the efforts🤗🤗🤗
@Akash-yr2if
@Akash-yr2if Жыл бұрын
Gained some Brain Cells After doing the Optimized, Still getting in my head, Damn Solution 🤯🤯
@krishanubiswas6869
@krishanubiswas6869 8 ай бұрын
Thanks striver, ....however i would like to mention my code....when i solved the code by myself....i used a treemap to keep an account of the zeroes.....and then iterated through the map turning all the stored rows and columns to 0....however actually this approach came to my mind from your vertical order traversal of binary tree where you used almost the same data structure....and my solution was accepted (though the T.C was bad)....but still thanks for helping to build me my own approach....and the optimal solution was superb...
@yashwairagade3677
@yashwairagade3677 4 ай бұрын
U r a legend bro i am impressed by your problem solving skills
@juliechoudhary9582
@juliechoudhary9582 Жыл бұрын
Understood and it's Amazing How you teach.
@AjayKumar-sx6qo
@AjayKumar-sx6qo 11 ай бұрын
OMG !!! Awesome explanation.. Thanks Striver
@NaveenKumar-xq6ce
@NaveenKumar-xq6ce Жыл бұрын
Your consistency is admirable @Striver
@sakthipriya8653
@sakthipriya8653 8 ай бұрын
Understood sir, very great explanation. I was very excited in the 7th minute itself. 🔥🔥🔥
@SaifUddin-mq1gk
@SaifUddin-mq1gk 3 ай бұрын
7 7 7 7 7 7 !!!!
@sukritinarang5016
@sukritinarang5016 5 ай бұрын
The brute force solution that set values to -1 instead of 0 will not work in some test cases as constraints are mentioned as -2^31
@AyushSharma-ye1xz
@AyushSharma-ye1xz Жыл бұрын
All videos are very helpful ❤️
@tridibeshmisra9426
@tridibeshmisra9426 5 ай бұрын
Very good algorithm .... the optimal one is really good. Thanks a lot, sir!
@sunnyvlogs__
@sunnyvlogs__ Жыл бұрын
Literally Awesome Explanation , easiest way
@CodingEnv
@CodingEnv Жыл бұрын
You are the soul and heart of DSA.
@mgnfy-view
@mgnfy-view 10 ай бұрын
Beautiful explanation!
@FooBar-lb5wf
@FooBar-lb5wf 2 ай бұрын
Amazing explanation, thank you! For the second pass through the array, I tried a slighly shorter approach which seems to work as well (tested on Leetcode). Process the elements bottom to top, right to left. This ensures that an element (i,j) is always updated before its row indicator (matrix[i][0]) and col indicator (col0 if j==0 else matrix[0][j]) are processed. We can then update them through single pair of loops over the array and we may not need special handling for matrix[0][0] and col0 elements.
@surabsebait5409
@surabsebait5409 Жыл бұрын
Understood, very clearly explained
@prathameshhatkar1911
@prathameshhatkar1911 Жыл бұрын
Great optimisation 🔥
@jeetdesaimusic
@jeetdesaimusic 2 ай бұрын
Crystal Clear Explanation!
@sanjayv-ef6ey
@sanjayv-ef6ey 15 күн бұрын
I have a seen a ad full for u bhai thanks
@hareshnayak7302
@hareshnayak7302 4 ай бұрын
Understood,Thank you striver for this amazing video.
@chethanprabhu4475
@chethanprabhu4475 Жыл бұрын
I had not understood when I watched it 2-3 days back. Looks like I had watched a video which was recorded 2 years back lol. But this new video is crisp clear
@takeUforward
@takeUforward Жыл бұрын
Yes re-rrecorded, the previous videos were for people who already knew dsa
@vivekpatial5614
@vivekpatial5614 Жыл бұрын
​@@takeUforward Your teaching skills are on another level :)
@ankitasharma3930
@ankitasharma3930 11 ай бұрын
thank you so much for such a great effort.
@RaviKumar-sn6tu
@RaviKumar-sn6tu 4 ай бұрын
watched your video ...then others video...then again your video ...then finally understood it😇😇
@AdarshKeshari-wc2uz
@AdarshKeshari-wc2uz 2 ай бұрын
Understood after going through twice ❤❤ Best explanation
@prashantsharma7869
@prashantsharma7869 6 ай бұрын
best explaination ,just love it!!
@luckydev9006
@luckydev9006 11 ай бұрын
Thank you for providing such good content
@rajatrathore5455
@rajatrathore5455 Жыл бұрын
Understood , great explanation
@subhambachar
@subhambachar Ай бұрын
just blew my mind, The OP optimal approach 🤯🚀
@ankush8243
@ankush8243 6 ай бұрын
Thank you so much🥰 Very much helpful !!
@TheEleetcoder
@TheEleetcoder Жыл бұрын
inspired by you and making videos like you!
@RahulYadav-jk7um
@RahulYadav-jk7um 2 ай бұрын
Was able to come up with better solution but did little mistake in the implementation , happy to see that I am now able to come with logical approach to solve problems All thanks to striver bhaiya! ❤
@shivammotani
@shivammotani Жыл бұрын
IDK why I felt the older video was more good. Found that one to be better. Even optimal code for that one is easier to understand.
@user-ik3qu5uy5e
@user-ik3qu5uy5e 5 ай бұрын
AMAZING SIR , UNDERSTOOD VERY WELL
@rishabhkala2115
@rishabhkala2115 Жыл бұрын
thanks for this explanation understood everything
@mashkoorahmad1885
@mashkoorahmad1885 Жыл бұрын
NEXT LEVEL man 😍😍🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥loved your videos
@shloksuman8164
@shloksuman8164 Жыл бұрын
Optimal approach was quite tedious to understand, however , I got it after writing down the code again myself
@takeUforward
@takeUforward Жыл бұрын
Yes that is the reason I went slow and long, but writing it yourself helps to clear so many things.
@karanveersinghdeora5085
@karanveersinghdeora5085 Жыл бұрын
Understood very well
@smileyyyy7372
@smileyyyy7372 Ай бұрын
May god bless you striver 🙏🙏
@user-yw6zj3ir8p
@user-yw6zj3ir8p 6 ай бұрын
crystal clear approach
@abdulrehmaan153
@abdulrehmaan153 Жыл бұрын
You just added one more #fan in your infinte length array ❤
@prasoonmishra995
@prasoonmishra995 Жыл бұрын
Awesome 👍
@pallavi22222
@pallavi22222 Жыл бұрын
Superb Explaination
@myyoutubeisthis
@myyoutubeisthis Жыл бұрын
Thank you sir you're great.
@shivamgurjar8979
@shivamgurjar8979 3 ай бұрын
Such a great solution ✨
@ddevarapaga5134
@ddevarapaga5134 Ай бұрын
wow mindblown amazing understood bro
@poojithkumar2283
@poojithkumar2283 Жыл бұрын
good approach👏👏👏
@user-cz4lk8qi2q
@user-cz4lk8qi2q 5 ай бұрын
Amazing Bhaiya !
@parthtiwari8152
@parthtiwari8152 11 ай бұрын
Loved ❤ ... Understood
@AnkitYadav-sk4nw
@AnkitYadav-sk4nw Жыл бұрын
Thank you Bhaiyaa!❤ ❤
@user-ui6op1zc2q
@user-ui6op1zc2q Жыл бұрын
just awesome ♥
@samuelfrank1369
@samuelfrank1369 6 ай бұрын
Understood. Thanks a lot
@konankikeerthi
@konankikeerthi 2 ай бұрын
Understood. Thank you bro
@tamilmukbang3789
@tamilmukbang3789 3 ай бұрын
understood thank you so much bro
@NitinKumar-wm2dg
@NitinKumar-wm2dg Жыл бұрын
Understood bhaiya, thank you
@itsabhinav04
@itsabhinav04 Жыл бұрын
Understood, thanks :)
@priyotoshsahaThePowerOf23
@priyotoshsahaThePowerOf23 Жыл бұрын
First code in spreadsheet and got some feel🥵😱❣❣
@shivamsingh7817
@shivamsingh7817 Жыл бұрын
Thank you so much bhaiya ❤️❤️❤️❤️
@sreejitkar8044
@sreejitkar8044 7 күн бұрын
Hatss off brother🙌🙌
@karanhaldar755
@karanhaldar755 4 ай бұрын
thankjs a lot bro I've watched lots of paid videoes and after that i came here to this master piece playlist I have no words how much it helps me to crack a job guys do not buy any DSA courses just watch all the videoes it will be enough to crack any DSA interview🤗🥰🥰🥰🥰🥰🥰
@user-fw4kz3bb4g
@user-fw4kz3bb4g 4 ай бұрын
which course you got? PW?
@nivetha6167
@nivetha6167 Жыл бұрын
You gave me hope when it comes to dsa... I'm too late being misled by other videos, but now after discovering your sde sheet, I have started to figure everything out in a planned manner... soooo... thank youuuuuuuuuuuu!!!!
@bully9858
@bully9858 10 ай бұрын
u are literally me
@nivetha6167
@nivetha6167 10 ай бұрын
@@bully9858 all the best with your coding Journey :⁠-⁠)
@GOJOANDSUKUNAFAN
@GOJOANDSUKUNAFAN 2 ай бұрын
​@@bully9858bro is actually him🗣️ 🔥🔥
@SunnyYadav-zv7hp
@SunnyYadav-zv7hp Жыл бұрын
Love you so much bro
@Se7ven_Plays
@Se7ven_Plays Жыл бұрын
Thankyou. Bhai for videos 😶
@crazycyrus2861
@crazycyrus2861 Жыл бұрын
Awesome Vedio Brother
@satyammishra6363
@satyammishra6363 5 ай бұрын
For Brute force based solution, I think we should int_min or float("-inf), instead of -1, because -1 can be entry in matrix
@unlockyourfinance
@unlockyourfinance 3 ай бұрын
Exactly, even int_min can be in the array since -2^31 is the limit in question..
@MahaveerJanagouda
@MahaveerJanagouda 2 ай бұрын
​@@unlockyourfinance​ u both are right, but how to approach it then? i tried int_MIN+1 also , 191 test casepassed for the first approach
@YourCodeVerse
@YourCodeVerse 9 ай бұрын
Understood✅🔥🔥
@nagame859
@nagame859 Жыл бұрын
Understood sir🤩
@GhostVaibhav
@GhostVaibhav Жыл бұрын
Understood🔥
@shikhajoshi8961
@shikhajoshi8961 11 ай бұрын
Understood Sir💗🙏
@user-tm1hu4cw3v
@user-tm1hu4cw3v 2 ай бұрын
Bro i got confused to m*n and n*m matrix pls check confirm your better solution by the way mine was like storing pairs almost the same...
@user-ui9fw7qj5n
@user-ui9fw7qj5n 7 ай бұрын
understood striver Thanks
@vardhamanbhandari5644
@vardhamanbhandari5644 Жыл бұрын
Understood🙌🙌🙌🙌
@yuvrajpatil925
@yuvrajpatil925 Жыл бұрын
Thanks 🙏
@sounaksaha1455
@sounaksaha1455 4 ай бұрын
One of the best optimal approach
@GOJOANDSUKUNAFAN
@GOJOANDSUKUNAFAN 2 ай бұрын
Yea bt you can't even imagine this 😭
@creativeprojects217
@creativeprojects217 6 ай бұрын
thank you sir❣
Rotate Matrix/Image by 90 Degrees | Brute - Optimal
17:47
take U forward
Рет қаралды 189 М.
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН
Stay on your way 🛤️✨
00:34
A4
Рет қаралды 27 МЛН
Why Is He Unhappy…?
00:26
Alan Chikin Chow
Рет қаралды 71 МЛН
Big-O Notation - For Coding Interviews
20:38
NeetCode
Рет қаралды 441 М.
Kadane's Algorithm | Maximum Subarray Sum | Finding and Printing
20:09
take U forward
Рет қаралды 365 М.
Fastest Way to Learn ANY Programming Language: 80-20 rule
8:24
Sahil & Sarra
Рет қаралды 808 М.
Pascal Triangle | Finding nCr in minimal time
26:45
take U forward
Рет қаралды 213 М.
Next Permutation - Intuition in Detail 🔥 | Brute to Optimal
28:15
take U forward
Рет қаралды 342 М.
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 633 М.
Count Subarray sum Equals K | Brute - Better -Optimal
24:09
take U forward
Рет қаралды 256 М.
Как бесплатно замутить iphone 15 pro max
00:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 8 МЛН