Error in my code


Please help finding error

@goyalvivek

I am using the same aproach, but not getting the ans, what is the error in my code?

hi @goyalvivek
there were 3 errors

  1. in base case add if n is 0, then return INT_MAX
dp[i] == INT_MAX; 

here u used = 2 times…
make it dp[i] = INT_MAX;
3. dp[0] will be 0, bcoz if there is only 1 element the min no of steps to reach end will be 0 only, as single element is only the last element…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.