Back to course home
0% completed
Vote For New Content
For bottom up solution, why don't isn't dp[3] initialized to fee[0], like dp[1] ...
Gary
May 11, 2022
For bottom up solution, why don't isn't dp[3] initialized to fee[0], like dp[1] and dp[2] since the min fee is just cost of taking 3 steps from the 0 index? Then the for loop would start at 3 instead of 2.
0
0
Comments
Comments
G
Gary 3 years ago
oh, because we need to go BEYOND the top step, I see.
A
Anamitra Datta3 years ago
you can initialize dp[3] to fee[0] too and start from index 3, that will give the same solution (that's what the java solution is doing)
On this page