In the problem SUPW

In SUPW
dp[0] = arr[0]
but why dp[1] = arr[1] ?
shouldn’t it be dp[1] = min(arr[0] , arr[1] );
because if the array only had two elements {2 3}
then do[0] = 2 dp[1] = 2 also because we can do arr[0] instead of arr[1] .If am I wrong in my concept correct me please.

@anirbandas0206 whenever we have to print dp[i] we always consider min(dp[n-1], dp[n-2], dp[n-3]) but we cant start dp 2 with min of dp1 and dp2 coz we need the actual values of a[1]a[2]a[3] to find the initial value of dp4

1 Like