I need your support, and you can do that by giving me a like, and commenting "understood" if I was able to explain you.
@ManishKumar-ui1tf2 жыл бұрын
Please Upload the next One video
@dhrubajyoti37742 жыл бұрын
Understood 🥺🥺
@somyadebsarkar65932 жыл бұрын
Can't we start from 0 and using recursion ?
@shubhamjha57382 жыл бұрын
koi compiler theek krao yrr python vla coding ninjas ka
@vishalkumarshaw92082 жыл бұрын
We are with u.
@KaushalDhruw6 ай бұрын
2 years later. Still the ultimate and unbeatable learning resource in the market.
@salmanpandey81504 ай бұрын
But i thought adita verma was best for dp
@riyasinghal26712 ай бұрын
@@salmanpandey8150yrr usne to mujko kisi pe bhi recursion karna bata diya bina soche uska base case nikap deta hun
@sanketdas70002 жыл бұрын
The dp series is like web series. Every day a new episod is coming with lots of new things and leaving a suspence for the next one.. thank you striver for this wonderful effort..and "UNDERSTOOD"..
@skiver97632 жыл бұрын
only if we could get a trailer for the next day's video😂
@jayantmishra6897 Жыл бұрын
this is the only playlist on youtube where you will find only positive comments because this man really put his effort to make this playlist valuable. thank you so much striver.
@manikantadevadiga7146 Жыл бұрын
i can see 2, striver and love babbar
@jeet-smokey4 ай бұрын
@@manikantadevadiga7146 Love Babbar copies from striver. I have seen many videos taking the same sample code and examples from striver.
@nitpBlogs3 ай бұрын
@@manikantadevadiga7146 Aditya Verma ka bhi dekh lo.
@haseebshaik86692 ай бұрын
After searching all over the world to grasp these DSA concepts, it wasn't until I watched this video that everything finally clicked. The way you explained it was beyond exceptional-thank you for creating such a clear and impactful resource!
@adarshanku79882 жыл бұрын
This series is so damn good that before watching this video, i thought of giving "min cost climbing stairs" question on leetcode a try because i felt i could do that. That is similar to this question only. And boom, i solved that question in all possible ways...recursion, memoization, tabulation and space optimised method. Thank you striver. You have kinda opened our brain and made our thinking broader. Thank you so much for the inspiration you are. Love you !!!
@balajiaadi19012 жыл бұрын
I recently started this dp series and i want to complete this series in 20 days this is my day 1 Thank you for this awesome series
@parthsalat2 жыл бұрын
Recursion code at 24:33 Memoization code at 25:25 Tabulation code at 30:54 Space optimization at 36:22
@prateeksaini85532 жыл бұрын
Thanks dude
@yournemesis82322 жыл бұрын
Would recommend to watch completely without skipping though The insights given by him are great
@parthsalat2 жыл бұрын
@@yournemesis8232 Yes, you are right. This is just for jumping to the desired explanation without wasting time - when you are revising
@sumitsanu9524 Жыл бұрын
You will get hired even if you can explain an interviewer till memoization thing but it will blow the mind of interviewer if you go till space optimisation to constant.... awesome video and striver is just god.
@alisharath16111 ай бұрын
Best video I have ever seen on DP. Thank you Striver for helping out fellow developers.
@026harshagarwal92 жыл бұрын
We will take a for loop running from j=1 to k and instead of writing (ind-1) and (ind-2) we will going to simply write (ind-j) that will give me the solution. Time Complexity:-O(N*K) Space complexity:-O(N). Yes sir, it cannot be space optimised because we have to use K+1 variables . Nice video and yes you are absolutely right, I have learnt space optimisation in dp from you THANKS MAN 👍👍
@cipherCrafters142 жыл бұрын
baniya buddhi mat chalao jyada striver bhai ko appreciate kaaro khud toh kuch kar nahi raahe
@Anonymous-lw4nq Жыл бұрын
@@cipherCrafters14 XD
@SuperSaber92 жыл бұрын
Amazing video! Do watch till the end because in the space optimization part, the actual value of watching the past two videos comes.
@PujaKumari-zl7rw2 жыл бұрын
Understood, Honestly this is the very first time I am trying to learn any dp problem. And I am able to understand everything... Very clear explanation. Loved it.. Thanks a lot for all the efforts :)
@ryanmathew639711 ай бұрын
your explanation is so good that even before you write the pseudo code, i was able to write the recursion by starting from 0 to n-1 rather than the reverse approach that you have taken in the video. Great Work you are doing. Helps to improve the way a person can solve a problem.
@SayanKarmakar3 ай бұрын
Learnt the concept, went straight to the editor, coded it in JAVA and submitted it...All test cases submitted 🔥👍 Striver's way of explaining recursion and DP is unbeatable and uncomparable
@taukirlalwala28652 жыл бұрын
Hey Striver! I tried solving this question myself and I was able to solve it, I must say this series is amazing. You started building my concepts in first 2 lectures itself. Gonna see your lecture now and look at your approach. Would surely complete whole dp series. Thank you for this series ❤
@niyammuliya57872 жыл бұрын
follow ups solution: #include int frogJump(int n, vector &heights, int k){ vector dp(n, INT_MAX); dp[0] = 0; for(int i=1; i
@letslearn1055 Жыл бұрын
this is what i thought in the very first second.
@kanishyathra Жыл бұрын
@@letslearn1055 me too
@DYashwanth-u3j Жыл бұрын
@@letslearn1055 same here when he said k jumps then i thought of a nested for loop till k
@uditgarg65087 ай бұрын
mee too
@adebisisheriff1599 ай бұрын
Thanks so much Striver. We really appreciate your effort. You are a rare gem.
@arghyadeepbhowmick2248 Жыл бұрын
Understood!! After seeing the recursion, I was able to convert it on my own into a dp. Thank you STRIVER. ❤
@xlr8tanmay3 ай бұрын
You need to learn Recursion bro
@banothutharun274310 күн бұрын
understood brother. You are the master of modern era of teaching dsa
@popularedits69842 жыл бұрын
UNDERSTOOD , Now I am loving dp its become easy to think from recursion to tabulation step by step, thank you so much for the hardwork!
@tanishkumar6682 Жыл бұрын
Hey, striver i just want to say that concept in your videos are such a crystal clear and easy to understand that even i am studying for the first time i do not feel any difficulty to understand the solutions. so, thank you so much for providing such a video lecture free on youtube
@ankitadas58332 жыл бұрын
Amazing video! Everything is clearly understandable. from day 1 of dp series I have watching your videos and Day by Day become big fan of your teaching way. God bless you sir. Came to know from your insta story that u have fever 🤒 Get well soon sir.
@pjagannadham25402 жыл бұрын
Yes his teaching is absolutely marvelous and I become big fan of him he keep rocking now I am happy to be cse student 😇😇
@SoyaibZihad1010 ай бұрын
I am nothing but greatful. Wanna finish the whole playlist. Thanks a lot
@parvathivanapilli85727 ай бұрын
Understood, Now I'm loving Dp Thank you Striver ❤
@firefly_3141 Жыл бұрын
Code Of Frog Jump #include using namespace std; //Top-Down Approach int dp1(int ind,vector&heights,vector&dp) { if(ind == 0) return 0; if(dp[ind] != -1) return dp[ind]; int left = dp1(ind-1,heights,dp) + abs(heights[ind]-heights[ind-1]); int right = INT_MAX; if(ind > 1) right = dp1(ind-2,heights,dp) + abs(heights[ind]-heights[ind-2]); return dp[ind] = min(left,right); } //Tabulation Method - Bottom Up Approach /* vectordp(n,0); dp[0]=0; for(int i=1;i 1) secondstep = dp[i-2] + abs(heights[i] - heights[i-2]); dp[i] = min(firststep,secondstep); } return dp[n-1]; */ //Space Optimization /* int prev=0; int prev2=0; for(int i=1;i1) secondstep = prev2+abs(heights[i]-heights[i-2]); int curi = min(firststep,secondstep); prev2 = prev; prev = curi; } return prev; */ int frogJump(int n, vector &heights) { vectordp(n+1,-1); return dp1(n-1,heights,dp); }
@gmh14 Жыл бұрын
At 25:23, can't you initialize the dp array for only n elements instead of n+1? Like you did for tabulation?
@studynewthings1727 Жыл бұрын
The code for k jumps: #Memoization def k_jumps(n,dp,arr,k,result): if n == 0: return 0 if dp[n] != -1: return dp[n] for i in range(1,k+1): if (n > (i - 1)): step = k_jumps(n-i,dp,arr,k,result) + abs(arr[n] - arr[n-i]) else: step = 9999999 result = min(result,step) dp[n] = result return dp[n] arr = [30,10,60,10,60,50] n = len(arr) k = 3 result = 999999 dp = [-1 for i in range(n)] print(k_jumps(n-1,dp,arr,k,result)) #Tabulation def k_jumps(n,arr,k): dp = [-1 for i in range(n)] if n == 0: return 0 dp[0] = 0 for index in range(1,n): result = 999999 for i in range(1,k+1): if (index > (i - 1)): step = dp[index-i] + abs(arr[index] - arr[index-i]) else: step = 9999999 result = min(result,step) dp[index] = result print(dp) return dp[n-1] arr = [60,30,10,60,10,60,50] n = len(arr) k = 3 result = 999999 print(k_jumps(n,arr,k))
@manideep7148Ай бұрын
I did not see this series feeling that DP is soo tough but after listening to your explanation, I've changed my mind. All credits to you Striver !
@satwiksrivastava3 ай бұрын
I managed to do the space optimization on my own! That's just how good your explanation is!
@pranavkutty57362 жыл бұрын
Understood! Your series is making me love DP. Thanks a ton! Excited for the next one.
@gajjalaharsha2 жыл бұрын
Can we write base case for n=1, then can write Math.abs(heights[1]-heights[0])?
@takeUforward2 жыл бұрын
Yes
@nikhilprasad6442 жыл бұрын
"UNDERSTOOD"..... Bhaiya pls upload practice problem link other than coding ninja link. Leetcode interface is best for easy understanding. I hope you understand , Thanks
@krishnachaitanya12652 жыл бұрын
Its not there on leetcode(Same problem)
@krishnachaitanya12652 жыл бұрын
Sadly leetcode is missing these kind of problems. No platform can match leetcode interface
@zaidshaikh25362 жыл бұрын
A similar problem on Leetcode is Min cost Climbing stairs 746
@nikhilprasad6442 жыл бұрын
@@zaidshaikh2536 bro i didnt ask for a similar problem on leetcode, I asked Striver bro to give the leetcode link and not the coding ninja link.
@kanhaiyaverma7391Ай бұрын
understood and I was always afraid of dp and now it looks easy.... Thank you!
@athangkulkarni824510 ай бұрын
Understood! Also, I could do tabulation and space optimization on my own after watching the explanation! A very big Thank you🥺
@simple_saviour44962 жыл бұрын
If possible pls provide leetcode problem link also of the particular problem since most of us are following leetcode
@zaidshaikh25362 жыл бұрын
Similar problem on Leetcode is 746
@Vishal-joshi19982 жыл бұрын
Count all possible palindrome in string with rearranging characters - Infosys 🙄
@SumitChauhan-vv5ix7 ай бұрын
This can be solve using combinatrix also , right??😅
@ArjunSehgal-gv1cc7 ай бұрын
semester 1 is about to start,and i am on this lecture,super confident>3000
@albatrossgeez66377 ай бұрын
bhai itna jaldi
@anukritigarg30392 ай бұрын
Understood!! I was always scared of Dynamic Programming but you made it so easy 🔥
@Cartooz01112 ай бұрын
this is the only playlist on youtube where you will find only positive comments because this man really put his effort to make this playlist valuable. thank you so much striver. ❤❤From Gujarat !! Jordar (Gujarati)!
@xlr8tanmay3 ай бұрын
Amazing explanation. Perfect solution to explain in an interview..
@vibhorbhatt3076Ай бұрын
This question became a piece of cake for the one's following previous vedios. Thankyou Striver Bhaiya.
@charoonigam956224 күн бұрын
Instead of prev, we can also return curi, right? same thing i guess? Rest all I understood, thanks Striver
@harshithaharshitha7927Ай бұрын
your intention is to make education easier...yes!! striver you did it....We learn from you.We will make you proud a Day...thankyou striver for this wonderful series..this is first comment on my youtube..try to ping my comment if u have time ❤
@abhisheknemade244410 ай бұрын
Thanks baiya very wonderfull video. I understood the video. Please make more and more videos. God will bless you. HK.
@ragnos6756 Жыл бұрын
Approach: Since the frog can make k jumps, we can use k recursive calls and find the minimum of them. used a variable ans to kept it as positive infinity to update the answer . base case is same as the frog jumps qn. but since frog can make k jumps, used a for loop to find the the answer for every jump (1st , 2nd ,.... till kth). also a check of i-w>=0 is made so that there is no infinite recursion. def frogJump(n,heights,k) -> int: i=n-1 ans=float('inf') def helper(i,ans): if i==0: return 0 for w in range(1,k+1): if i-w>=0: find=helper(i-w,ans)+abs(heights[i-w]-heights[i]) ans=min(find,ans) return ans return helper(i,ans) def frogjump_tabulation(n,heights,k): dp=[0]*(n+1) dp[0]=0 for i in range(1,n): ans=float('inf') for j in range(1,k+1): if i-j>=0: find=dp[i-j]+abs(heights[i-j]-heights[i]) ans=min(ans,find) dp[i]=ans return dp[n-1]
@VimanshMahajan9 ай бұрын
Take the base case of index == 1 as return abs(heights[1]-heights[0]), makes the code a bit simpler without if else conditions.
@VimanshMahajan9 ай бұрын
index == 0 condition stays as it is so basically two base cases
@urdaddy8520 Жыл бұрын
this space optimization technique is way too classic, thanks bhaiya
@thisismr900 Жыл бұрын
Understood! hauuwa bana rakha tha dp ka 1 saal se man mein thanks 900
@bhanderidhruvbhanderidhruv5576 ай бұрын
big thank you bhai for your hard work and make questions easy for us , again thank you with saying "we can't be lazy by seeing your high level of energy to teach us", "UNDERSTAND" 😍🥰🤩😇😘❤💘
@stith_pragya9 ай бұрын
Thank You Much for this wonderful video.............🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻
@suvarnakumarvasamshetty4 ай бұрын
Bro the way u explained is just amazing
@Happy-tf7se5 ай бұрын
As I am declaring the dp array globally it is giving incorrect answer. What could be the reason?? vector dp(100000,INT_MAX); int solve(int ind, vector& height){ if(ind==0) return 0; if(dp[ind]!=INT_MAX) return dp[ind]; int jumpTwo = INT_MAX; int jumpOne= solve(ind-1, height)+ abs(height[ind]-height[ind-1]); if(ind>1) jumpTwo = solve(ind-2, height)+ abs(height[ind]-height[ind-2]); return dp[ind]=min(jumpOne, jumpTwo); } int frogJump(int n, vector &heights) { // Write your code here. return solve(n-1,heights); }
@vibhavsharma27245 ай бұрын
understood this very well. Thanks to striver
@lokeshreddy41489 ай бұрын
I think it is the best solution to previous videos
@Harmless_creatureАй бұрын
00:03 Find the minimum total energy used by the frog to reach the first stair 02:13 The minimum energy required to jump from one point to another is 20. 06:11 Recursion is a way to find the path with minimum energy. 08:30 The costing for this guy will be zero no matter what you do. 12:51 Applying memoization to optimize recursion 14:47 Return the minimum of the left and right subpoints 18:51 Recursion helps solve multiple sub problems by reusing previously solved solutions. 20:50 Convert a recursion solution to dynamic programming 24:48 Memoization and tabulation are two approaches to solve problems recursively and iteratively respectively. 26:43 The first step in tabulation is to initialize the dp array. 30:55 The space complexity can be optimized by using the index minus 1 and index minus 2 technique 32:49 Use variables instead of an array to store previous values. 36:49 The problem requires k jumps as a follow-up to i plus 1 and i plus 2. 38:38 The ultimate resource for placements
@umber31179 ай бұрын
Understood. Amazing explanation. Thanks a lot for making these videos.
@dEviL_bIsWaJiT3 ай бұрын
Understood, Thanks a lot bhaiya ❤
@sonukumarram18808 ай бұрын
US , such a cool explanation ... thnx for this wndrful playlist
@ashusnapx Жыл бұрын
#include int frogJump(int n, vector &heights) { if(n == 0) return n; int left = frogJump(n-1,heights) + abs(heights[n] - heights[n-1]); int right; if(n > 1) { right = frogJump(n-2,heights) + abs(heights[n] - heights[n-2]); } return min(left,right); } whats wrong?
@sankalpsamitkumarpatel429 Жыл бұрын
declare right = MAX_INT.
@codewithom11 Жыл бұрын
US😎 Before the lecture, i was having a lot of fear about tabulation. Bt now its totally clear.😇 Thanks Raj Bhaiyya
@harshrajhrj Жыл бұрын
Very helpful and minute problems were explained nicely. Nothing best than this.
@NirmalyaMusicOfficial3 ай бұрын
Understood each step in detail 💯
@manasansh7198 Жыл бұрын
"UNDERSTOOD" Great series Striver
@joyassroybarua58612 ай бұрын
Thank you vai. Its really awesome. And love from Bangladesh
@rohan87586 ай бұрын
understood. Thanks for DP web series with addiction
@20arpitbhatnagarit7 Жыл бұрын
Instead of if clause sir you could have inserted the val of dp[1] and started loop from i = 2
@ajayprajapati7914 Жыл бұрын
Explanation is very high level❤❤❤
@ABHIMANYUTHAPLIYAL3 ай бұрын
Understood ! much appreciations to your efforts .
@jayujain2647 Жыл бұрын
Thanks a lot!!!! I was able to solve the video without seeing the video all because of you!!!!
@dibyajyotinayak2235 Жыл бұрын
Understood! Thanks for explaining beautifully!
@SethuIyer957 ай бұрын
I am actually watching this to give a google interview sometime later but god damn, this is actually fun to learn lol
@NaveenPGForYou10 күн бұрын
Best ever! There aint no one like Striver!
@jaatharsh Жыл бұрын
awesome, loved the clear n cripsh explanation
@kathanvakharia Жыл бұрын
Understood...Completed 3/56
@jagansubramanian523410 ай бұрын
Understand. Keep doing good work striver
@audioeditsnstuff Жыл бұрын
In space optimization can we also return curr as answer?
@digambardiwakar9535 Жыл бұрын
in this question was it necessary to make dp array of size n+1 or it was sufficient to make it of size n?
@aditi1729 Жыл бұрын
in the simple recursive solution, why do we need to make a new function f, can't we write the same recursive code inside fromJump function?
@KUMARSAURABH-s5i2 ай бұрын
facing problem while thinking for the base case of recursion!! is there any shortcut for it
@monisavaratharaj2 ай бұрын
US striver! TUF always takes us forward...No one can beat striver in explaining the problem
@beilulbilly26369 ай бұрын
Love the way you explained
@chandolumanishbabu6807 Жыл бұрын
Frog jump with k jumps: #include using namespace std; int min_dp(int n, vector &heights, int ind, vector &dp,int k) { if (ind == 0) return dp[0]=0; if (ind == 1) return dp[1] = abs(heights[ind] - heights[ind - 1]); if (dp[ind] == -1) { vector temp(k); for(int i=1 ; i> n>>k; vector heights(n); for (int i = 0; i < n; i++) { cin >> heights[i]; } int ind = n-1; vector dp(n + 1, -1); cout> t; while (t--) { solve(); } return 0; }
@MazharulIslam-f9v Жыл бұрын
yeah, Sir, I understood. your lecture is very informative..... thank you, sir.
@MDEMANURRAHAMAN-5 ай бұрын
Best explanations indeed, love you man.
@rajarshinath619411 ай бұрын
understood Sir... U are just GOD
@lifehustlers1647 ай бұрын
4/57 done!!! understood!
@ashusnapx Жыл бұрын
The doubt that i'm facing in the followup question is that if the frog can jump either i+1,i+2 all the way to i+k, then how can we make a tree consisting of left and right subtree? Okay no worries, let me check the next video and clear my doubt,,, i'm trying to be patient, whenever i feel that i can't solve this, i feel like i'm dumb 😂
@vijeshsshetty3 ай бұрын
Understood. Great Playlist !!!!
@NavaneethaKrishnan-g6x Жыл бұрын
UNDERSTOOD. Your explanation is damn good bro. thanks alot.❤
@G.Lakshmi_Prasanna Жыл бұрын
Clearly understood💯. Thank you so much for the series
@tasneemayham974 Жыл бұрын
Hey, Striver! I have a question please. What if I wrote my recursion with base case if(ind
@Anonymous-hj4zh4 ай бұрын
Thank you, understood very well
@amarnathghosh7983 Жыл бұрын
Will it work if I increment i in heights and dp? for example-> fs = dp[i] + abs(height[i]-height[i+1]) for the tabulation code, will this work?
@coder_077 ай бұрын
UnderStood Very well Thank You sir
@AiraJena-q7f8 ай бұрын
In the memorization code why int right= INT_MAX , what's the need of this initialisation?
@rishabh._.raj14 ай бұрын
how did you deciede the values of prev1,prev2 here? @takeUforward