great explanation. just one question. what is the thought process to convert top down approach to a bottom down approach? i struggle to make this conversion
def minCostClimbingStairs(self, cost: List[int]) -> int: def find_min_cost(i,memo={}): if i in memo: return memo[i] if i < 0: return 0 if i == 1 or i == 0: return cost[i] memo[i] = cost[i] + min(find_min_cost(i-1),find_min_cost(i-2)) return memo[i] return min(find_min_cost(len(cost)-1),find_min_cost(len(cost)-2)) I feel this is the right way to solve by top down approach. @Lead Coding by FRAZ
NoT Any Space.................! TC O(n) class Solution { public int minCostClimbingStairs(int[] cost) { for (var i = cost.length-3; i >= 0; i--) cost[i] += Math.min(cost[i+1], cost[i+2]); return Math.min(cost[0], cost[1]); } } // optimised
Hey i wanted to ask you like I am in 2nd year nd I am too doing 2 leetcode problem everyday and 2 cp problem... What should I do to improve my problem solving skills And is it too late to start now
c++ solution:
int minCostClimbingStairs(vector& cost) {
for(int i=cost.size()-3;i>=0;i--)
cost[i]=min(cost[i]+cost[i+1],cost[i]+cost[i+2]);
return min(cost[0],cost[1]);
}
No matter how much i look at the solution i just cant understand why this is why i struggle with solving leetcode problems
great bro plz upload more videos
Yes i will be
Got a good youtube video on dp👍🙏 thank you
Bhaiya
thanks.
Best video on a DP problem !! It shows not only the solution but the entire thought process behind solving the problem. Keep up the good work .
As clear as crystal.
thanks :)
This is so awesome. Thank you...
big thumps up
please share with friends :)
Best Explanation for this problem!
great explanation. just one question. what is the thought process to convert top down approach to a bottom down approach? i struggle to make this conversion
same problem
def minCostClimbingStairs(self, cost: List[int]) -> int:
def find_min_cost(i,memo={}):
if i in memo:
return memo[i]
if i < 0:
return 0
if i == 1 or i == 0:
return cost[i]
memo[i] = cost[i] + min(find_min_cost(i-1),find_min_cost(i-2))
return memo[i]
return min(find_min_cost(len(cost)-1),find_min_cost(len(cost)-2))
I feel this is the right way to solve by top down approach.
@Lead Coding by FRAZ
Great explanation
Thanks 🔥
really struggling in Dp problems please create a dp playlist if u can that will be more helpful
Thanks for this great explanation!
doing great job!
Thanks bro ❤️
NoT Any Space.................!
TC O(n)
class Solution {
public int minCostClimbingStairs(int[] cost) {
for (var i = cost.length-3; i >= 0; i--)
cost[i] += Math.min(cost[i+1], cost[i+2]);
return Math.min(cost[0], cost[1]);
}
}
// optimised
The explanation was so clear! Thank you so much for such a detailed explanation.
Subscribed immediately :)
Welcome! and thanks for subscribing
Hey i wanted to ask you like I am in 2nd year nd I am too doing 2 leetcode problem everyday and 2 cp problem...
What should I do to improve my problem solving skills
And is it too late to start now
You are doing good. Just be consistent and it's not late
Thanks for this great explanation!