DP 5. Maximum Sum of Non-Adjacent Elements | House Robber | 1-D | DP on Subsequences

  Рет қаралды 382,044

take U forward

take U forward

Күн бұрын

Lecture Notes/C++/Java Codes: takeuforward.org/data-structu...
Problem Link: bit.ly/3q5rlUY
Make sure to join our telegram group for discussions: linktr.ee/takeUforward
Pre-req for this Series: • Re 1. Introduction to ...
Full Playlist: • Striver's Dynamic Prog...
In this video, we have discussed how to solve the problem of the maximum sum without taking adjacent elements. Here the concept of pick non pick has been explained.
If you have not yet checked our SDE sheet, you should definitely do it: takeuforward.org/interviews/s...
You can also get in touch with me at my social handles: linktr.ee/takeUforward

Пікірлер: 3 800
@takeUforward
@takeUforward 2 жыл бұрын
I need your support, and you can do that by giving me a like, and commenting "understood" if I was able to explain you.
@aakashagarwal146
@aakashagarwal146 2 жыл бұрын
Understood bro
@dhrubajyoti3774
@dhrubajyoti3774 2 жыл бұрын
Understood 🥺
@tcob33yashambekar48
@tcob33yashambekar48 2 жыл бұрын
Understood 👍👍
@kunjparekh4632
@kunjparekh4632 2 жыл бұрын
Understood
@jasmeenkaur6001
@jasmeenkaur6001 2 жыл бұрын
Understood😁
@ankitadas5833
@ankitadas5833 2 жыл бұрын
Understood Sir. At 3:50 min of the video I paused it and went to the recurrence playlist, then watch lecture no 6 & 7 thoroughly and then came here .Amazing session .Thank You Sir for helping us to improve our skills.
@takeUforward
@takeUforward 2 жыл бұрын
Thanks 😊
@YahyaMohammed-gh7np
@YahyaMohammed-gh7np 6 ай бұрын
Believe me I have been trying to solve dp problems since 6 years and never came across this playlist. Amazing learning technique. This will surely help me in cracking interviews.
@anoopsingh36
@anoopsingh36 6 ай бұрын
Initially I was not able to understand anything related to DSA. I thought that I am not for this. But when i started seeing your videos I found that what I was lacking was a good teacher who is able to understand such advance complex concept in matter of minutes in the best simple way possible. I would have never imagined myself solving hard level dsa questions without you. Thank you sir for all your efforts . Please continue teaching. We will be always with you. THank YoU.
@user-fb1yo8fb3i
@user-fb1yo8fb3i 7 ай бұрын
You explained so well, dp was to be hard topic for me but after watching your videos the thought just reversed. Keep going. Most hardworking man i ever seen.
@decepticonWave
@decepticonWave Жыл бұрын
I love it when you get so excited and start speaking your native language. You are amazing striver
@akashsardar495
@akashsardar495 2 жыл бұрын
This is indeed the best DP series. Thanks for providing such quality content for free. I'm really enjoying it.
@TurboTalesShortsYT
@TurboTalesShortsYT 4 ай бұрын
ur teaching method is just awesome....no one in the entire KZfaq world has made such a best video on DSA. lots of love from my side.🤟🥰
@shetty-m4d
@shetty-m4d Ай бұрын
I never had a habit of commenting. But the way you are teaching makes me enthusiatic towards dsa understood each and every concept following from array to dp was a long journey. It wasnt possible without .once again thank u bhai❤
@anuragprasad6116
@anuragprasad6116 Жыл бұрын
I got confused when you wrote f(ind) at 7:57. Immediately, the pop up rectified the mistake. It's amazing how much work has gone in these videos! I'm loving the playlist till now! Keep up the good work man. Your inputs to the community are huge and they will definitely return back to you in one way or another. Best wishes!
@dharssinikarthikeyan4760
@dharssinikarthikeyan4760 9 ай бұрын
Thanks for this comment, I was confused and noticed only after you say!
@deepakojha3216
@deepakojha3216 2 жыл бұрын
what an energy man....!!! ❤The way you teach make me fall in love with the programming .....!!
@neharathod637
@neharathod637 6 ай бұрын
Understood!! Thank you for all the efforts in putting up such an amazing playlist! Really sparks my interest in DP, knowing the thought process behind solving every problem. Keep up the good work!
@057ahmaransari5
@057ahmaransari5 7 күн бұрын
what a content it's amazing . DP becomes easy for me till now because of you. Thank you so much.
@user-nq7nt1rq9b
@user-nq7nt1rq9b 2 жыл бұрын
This is my 1St comment on this channel Really he is explaining the thought process which should be come when we are solving problems
@abhinavgupta5641
@abhinavgupta5641 Жыл бұрын
The energy while teaching is just awesome man even a sleepy head can understand the concept u teaches, Hats off!❤
@DuyPham-sq5qe
@DuyPham-sq5qe 4 ай бұрын
The way he teaches is detailed and easy to understand. Thanks a lot!!!
@sudhanshuraj8080
@sudhanshuraj8080 7 ай бұрын
This is just the 4th lecture, I struggle a little bit while writing recursive solution, but memoising it, and then tabulating it, and then space optimizing it has become so easier, i never thought dp would be fun. Thank you sir!
@eshupatel3902
@eshupatel3902 2 жыл бұрын
Hats off to this guy whenever we discuss about dp, people just start with tabular method no one teaches how to apprach that, what is the intution behind that approach but this guy making the concepts crystal clear. Thank you so much bhaiya😇
@abirhussain6033
@abirhussain6033 Жыл бұрын
I can find the recurrence relation of a problem and determine whether it is a dynamic programming problem by determining if there is any overlapping sub-problem. The interesting fact is that I have learned these from this playlist. Thanks a lot, bro.
@anusuyaganguly6009
@anusuyaganguly6009 10 ай бұрын
us. understood in one go ! and DP never seemed so easy before this video . keep up the good work.
@rohangupta4290
@rohangupta4290 5 ай бұрын
Man you are a genius when it comes to teaching!!
@adarshanku7988
@adarshanku7988 2 жыл бұрын
Instead of adding base case as if(ind
@shreyaagarwal6746
@shreyaagarwal6746 3 ай бұрын
I was struggling with this basecase and was missing to apply the max method considering the arr[0] too. Thanks for commenting this out.
@chetanraghavv
@chetanraghavv 2 жыл бұрын
I think we can write one more base case for index = 1. Like 0, when 1 is reached then it means element at 2 wasn't selected and we want to maximize sum so we can select either nums[0] or nums[1] so return max(nums[0], nums[1]) as we need to maximize sum. By doing so we can omit the line that is returning 0 when n < 0 Thanks Striver, Wonderful explanation!
@thisismr900
@thisismr900 11 ай бұрын
I have watched your 4 DP lectures and trust me I was able to solve this question in in one go. even pehli bar DP touch kiya , from today itself This is your contri ! US!!!
@nourhanessam9633
@nourhanessam9633 9 ай бұрын
Words are not enough to describe this perfect explanation, keep going please.
@SHASHANKRUSTAGII
@SHASHANKRUSTAGII 2 жыл бұрын
The way you explain na, aisa lagta hai ki you yourself enjoy this, and that is why your basics are so clear. Keep it up. Google ka CEO banoge ek din.
@dineshchoudhary8635
@dineshchoudhary8635 Жыл бұрын
@@utkarshsharma6650 app bi
@Bharat_Rider
@Bharat_Rider 7 ай бұрын
US
@eklavya22k34
@eklavya22k34 6 ай бұрын
So TRUE. Striver enjoys coding. Coding is Fun for many geeks.
@surabhsaxena7928
@surabhsaxena7928 2 жыл бұрын
Your enthusiasm and energy grabs my entire focus on the topic🔥🔥.. thank you for the series🙏🙏 "understood"
@biswajitsaha6773
@biswajitsaha6773 6 ай бұрын
Fully understood dada, your explanation is more than enough to write the actual code by ourselves!
@KaushalDhruw
@KaushalDhruw 4 ай бұрын
Your explanation is amazing, and your enthusiasm.. contagious. Can't thank you enough man.
@phatcat7924
@phatcat7924 Жыл бұрын
This is the best dp series of all time. Thank you striver for all the efforts you put in this.
@aprekshamathur6143
@aprekshamathur6143 2 жыл бұрын
thank u for this dp series. It's actually clearing my concepts.
@aakashyadav8142
@aakashyadav8142 9 ай бұрын
Understood and very much liked you teaching technic. I admit you as a role model.🔥🔥🔥 Awesome sir
@shreyajain5058
@shreyajain5058 20 күн бұрын
"US"❤ the only channel which makes me understand all these problems so easily. Thankyou so much sir!!
@aryangupta9062
@aryangupta9062 Жыл бұрын
Striver has to be the craziest guy, came here to get through placements ended up wanting to code for fun!!! Understood concept very well!!
@divyaporwal589
@divyaporwal589 2 жыл бұрын
Best playlist ever of dp....and you have proved it✌️
@user-ho7zu2mi7c
@user-ho7zu2mi7c 7 ай бұрын
Understood !! I know you are striver but for us you are a saviour..!
@karthikk2316
@karthikk2316 6 ай бұрын
hands down the besttt ever video i have ever seen i solved this robber problem using kind of pattern but why i never understood how did it work ...but i always wanted to know how it works internally....but i have to say now that i hate that kind pattern orinted dp problem instead i love this memo and space idea.....Hats off!!!striver bhai❤
@bhagyabeebaruah4900
@bhagyabeebaruah4900 2 жыл бұрын
Falling in love with programming ❤️ all credit goes to you ..the way you teach is just🔥🔥
@KuldeepSingh-ru9ok
@KuldeepSingh-ru9ok 2 жыл бұрын
Its good to watch good content for free.. I just finished recursion playlist and now watching DP. For me it is a hard topic, tabulation technique is most difficult but i hope i will get it by the end of this playlist. (NON-CS BACKGROUND)
@shriRadheHariom
@shriRadheHariom Ай бұрын
Great explanation Sir, You teach each and every concept with accuracy.Thanks a lot.
@bhupendramaurya6587
@bhupendramaurya6587 7 ай бұрын
Understood bhaiya with so much clarity, Thank you so much for providing content like this. Thank you again bhaiya
@khushisingh6651
@khushisingh6651 2 жыл бұрын
bhaiya you are the best i mean i was confused with dp for so long time and this was becoming the only topic which I was afraid to cover but now my concepts are getting clear and thankyou so much for this series at this time since this will help me do goood in my internships thankyou bhaiya 🥰🤩
@TheAI-Tutor
@TheAI-Tutor 7 ай бұрын
Kya haal hai khushi 😏
@devankmaheshwari2712
@devankmaheshwari2712 Жыл бұрын
it was literally the best series . i am myself to able to code recursion problems now and its boosting my confidenece and also bhaiya the space optimisation part is just awesome yar
@birjeshgupta2003
@birjeshgupta2003 5 ай бұрын
UnderStood , u are literally teaching in very nice manner.
@vidyotma6043
@vidyotma6043 10 ай бұрын
Understood sir, Your content is really of very good quality and make us how we can analyze the problem and think of approach. Really appreciable.... Thankyou sir
@karthikeyansivakkumar5075
@karthikeyansivakkumar5075 2 жыл бұрын
Understood buddy. As usual, great explanation. Get well soon too. Just a request. Need a little more clarity on how to identify whether to approach as a greedy algo or dynamic programming pattern just by looking at a problem.
@takeUforward
@takeUforward 2 жыл бұрын
Generically if u see greedy failing, switch to trying all cases by recursion. For this u need your brain to generate test cases and figure this out that greedy is failing.
@aakashagarwal146
@aakashagarwal146 2 жыл бұрын
As much as I can think if the data is sorted and have uniform difference between them then I think we can go with greedy else dp Correct me if I am wrong plz
@shaamidrees6036
@shaamidrees6036 2 жыл бұрын
@@aakashagarwal146 not uniform but some sort of increasing difference In coin change problem greedy works for 1,2,5,10,20.... becz difference is 1,3,5,10 which is in order and not overlapping but in cases where difference is overlapping or not in any order like when coins are 2,3,6,7. here greedy fails becz the difference is 1,3,1 which is overlapping hope you got the idea
@parthsalat
@parthsalat 2 жыл бұрын
In space optimizations, it's better to initialise things like this: int pre1 = nums[0]; int pre2 = nums[0]; int curr; Just because this makes more sense.
@googlewasmyidea9895
@googlewasmyidea9895 Ай бұрын
bruh, prev2 needs to be 0 because also if the negative check is omitted it'll work fine.
@mathy642
@mathy642 7 ай бұрын
Hey Striver, The way you are explaining is really awesome and it is helping us to solve on our own :)
@mendahaseena7901
@mendahaseena7901 Күн бұрын
your way of solving DP problems really helpful for me. Thanks a lot
@beinghappy9223
@beinghappy9223 2 жыл бұрын
Bhaiya Codestudio platform is lagging many a times , could u please provide problem links of similar type that are available on gfg , leetcode , codeforces, codechef etc for practice
@AbhishekSingh-hi5eq
@AbhishekSingh-hi5eq 11 ай бұрын
House robber problem on leetcode
@gajjalaharsha
@gajjalaharsha 2 жыл бұрын
Can we write base case for 1 if(n==1) return max(a[0], a[1])
@lesGo.8963
@lesGo.8963 2 жыл бұрын
yes but that is only if the size of the vector is more than 1
@varadpanchal1231
@varadpanchal1231 2 ай бұрын
BEST DP PLAYLIST EVER
@AppaniMadhavi
@AppaniMadhavi 2 ай бұрын
Understood and solved on my own, thank you striver for the amazing lectures!!!
@suyashjain3223
@suyashjain3223 9 ай бұрын
Amazing Explanation Striver!! Understood all the concepts taught in the video.
@stith_pragya
@stith_pragya 7 ай бұрын
UNDERSTOOD............Thank You So Much for this wonderful video.........🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@ShreyaKarn-q2f
@ShreyaKarn-q2f Ай бұрын
"Understood". Another amazing lecture!!
@shigoeditz7079
@shigoeditz7079 Ай бұрын
Understood !!!!! Thankyou so much Striver
@Anonymous-th8sg
@Anonymous-th8sg 7 ай бұрын
sir watching now, and we support you for this wonderful content you are making for us. Much love sir❤
@sujalgangrade7333
@sujalgangrade7333 4 ай бұрын
Really Amazing explanation I am able to understand each and every concept very clearly 😇😇
@deepikabinjola2084
@deepikabinjola2084 6 ай бұрын
understood completely😊 as your way of teaching is amazing !!👏
@codecrafts5263
@codecrafts5263 7 ай бұрын
Understood. I watched this question on some other youtube channel but this one was far better.
@raaviumasusmitha937
@raaviumasusmitha937 2 ай бұрын
@striver your efforts are really amazing!
@anuj.gupta__
@anuj.gupta__ Ай бұрын
Wow man!! Understood everything
@aruna5869
@aruna5869 7 ай бұрын
@25:18 Intro to space optimisation🔥😂❤.Thank you very much. Crystal clear explanation❤🙏
@user-xq1ee8zy3k
@user-xq1ee8zy3k 10 ай бұрын
Understood .Quality teaching bro.Thank u so much.
@aakashshivanshu3578
@aakashshivanshu3578 9 ай бұрын
Thanks you striver for such an amazing tutorial. Your recursion playlist and now this DP series is building an amazing confidence inside me .Now I feel that I can solve the DP problems easily.
@shubh625
@shubh625 20 күн бұрын
hi
@user-to3jj8lj8h
@user-to3jj8lj8h 24 күн бұрын
"US" what the heck man, that space optimization is just superbb. thankyou so much striver.
@idocoding2003
@idocoding2003 8 ай бұрын
Sir.... You are legend... Only one word to describe you
@user-zm9qn2sp3h
@user-zm9qn2sp3h 10 ай бұрын
Thanks for providing such quality content for free. "understood".
@Abcd-jt1qs
@Abcd-jt1qs 2 ай бұрын
Understood sir! Thank you for these amazing lectures :)
@VivekSharma-eh2tv
@VivekSharma-eh2tv Ай бұрын
the space optimization is the so good , i feel so understood .
@babitakumari2172
@babitakumari2172 3 ай бұрын
Solved it myself , thanku so much to make the dp concept easy
@yogeshrajput6331
@yogeshrajput6331 5 ай бұрын
amazing explaination what a style of teaching
@user-bt6mh9ez3u
@user-bt6mh9ez3u Ай бұрын
Understood!!Amazing Videos
@raghavmanish24
@raghavmanish24 Ай бұрын
you are legend for dp playlist
@thisisRandom-ut9iq
@thisisRandom-ut9iq 9 ай бұрын
I am a huge fan of yours. Please please do all data structures topic like Greedy,.....etc.
@arastusharma439
@arastusharma439 6 ай бұрын
Understood !!! Amazing Lecture 👌
@sahilrepuriya3205
@sahilrepuriya3205 4 ай бұрын
Understood , now dp seems easy to me thank you so much sir 💙
@nikunjsoni123
@nikunjsoni123 3 ай бұрын
Understood: wonderful explanation! Thank you Sir!
@deepakbhatt555
@deepakbhatt555 8 ай бұрын
Thanks for these kind of videos. It is helping a lot.
@harshkoshti4588
@harshkoshti4588 5 ай бұрын
Finally i understood how recursion is working in this program 😊
@harshal.petkar04
@harshal.petkar04 Ай бұрын
Excellent.....Amazing.....fabulous.........
@manasansh7198
@manasansh7198 10 ай бұрын
Understood Striver great effort from your side
@akankshaverma9999
@akankshaverma9999 Ай бұрын
Amazing content. Thanks alot
@pardhi8959
@pardhi8959 4 ай бұрын
Salute for your hard work
@UnnatiMishra-hb6he
@UnnatiMishra-hb6he 2 ай бұрын
Amazing Lecture!!!!
@dewsara2888
@dewsara2888 Ай бұрын
Thanks a lot. You are awesome. Understood very well.
@amandubey9296
@amandubey9296 3 ай бұрын
Thank You Soo much Sir, I went for to much resourse to learn DP but your playlist is just awesome🙂. "US"
@user-qq5bb7bh5z
@user-qq5bb7bh5z 10 ай бұрын
hats off to your efforts
@Upscwithconsistency2025
@Upscwithconsistency2025 9 ай бұрын
understood sir...great explaination.
@satyamgade2043
@satyamgade2043 10 ай бұрын
"US" .... absolutely the best teacher ❤
@RohitVerma-yb4ch
@RohitVerma-yb4ch 10 ай бұрын
Thanks!! I am finally understanding DP :D
@NazeerBashaShaik
@NazeerBashaShaik 8 ай бұрын
Thanks for great explanation.
@aradhyapandey1489
@aradhyapandey1489 10 ай бұрын
bhaiya kyaaa padhate hoo👌, bhayankar🤯🤯 maja aajata hai👍👍
@sonuanand167
@sonuanand167 2 ай бұрын
Understand.. striver (Raj).. Bhai gajab..
@imtiyazalam_IIItian
@imtiyazalam_IIItian 2 ай бұрын
thank you so much bhaiya for this amazing playlist
@cricket-lo8fk
@cricket-lo8fk 10 ай бұрын
understood ,Awesome explanation❤❤❤
@nourhanessam9633
@nourhanessam9633 8 ай бұрын
Amazing explanations, keep going please.
@amankumarsingh4824
@amankumarsingh4824 20 күн бұрын
Understood! Thank You Sir!
@stain0p101
@stain0p101 11 ай бұрын
Understood the whole concept. Awesome video sir.
@preetisahani5054
@preetisahani5054 10 ай бұрын
Understood, awesome explanation.
DP 6. House Robber 2 | 1D DP | DP on Subsequences
9:50
take U forward
Рет қаралды 276 М.
Kadane's Algorithm | Maximum Subarray Sum | Finding and Printing
20:09
take U forward
Рет қаралды 368 М.
Schoolboy - Часть 2
00:12
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 11 МЛН
Алексей Щербаков разнес ВДВшников
00:47
Inside Out Babies (Inside Out Animation)
00:21
FASH
Рет қаралды 24 МЛН
Launching the best DSA Course + Platform
36:29
take U forward
Рет қаралды 134 М.
How To Think Like A Programmer
1:00:07
Coding Tech
Рет қаралды 2 МЛН
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36
Sahil & Sarra
Рет қаралды 634 М.
DP 3. Frog Jump | Dynamic Programming | Learn to write 1D DP
38:50
take U forward
Рет қаралды 519 М.
5 Simple Steps for Solving Any Recursive Problem
21:03
Reducible
Рет қаралды 1,2 МЛН
Schoolboy - Часть 2
00:12
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 11 МЛН