AtCoder DP Question

Hi! I’m solving this question. But I’m not able to come up with recursion solution.
Question - https://atcoder.jp/contests/dp/tasks/dp_a
Here is my code - https://ide.codingblocks.com/s/54601
Thanks!

value[i]=min( value[i-1] + | h[i] - h[i-1] | , value[i-2]+|h[i]-h[i-2]| ).
This is the recurrance relation.
O(N) complexity
Hit like if u get it

1 Like

This the bottom up solution I want to solve it using top down approach.

you can use this solution in both top down and bottom up approach.
this is only a relation which u will use in DP.:slight_smile:

1 Like