Dp minimum number of steps

please check int his code … it is running successfully for the elements less than 1000 but greater than that run time error is coming

You’ve taken the size of dp[] array t be 1000, increase that size