I was doing a program in which I have to find out minimum no of steps to reach the end of array but it gave me time limit error

I was doing a program in which I have to find out minimum no. of step to reach end of array but it is giving time limit exceeded error.
can you please help me how can I optimize my code.

Bro this is a dp problem not greedy problem. Have you done Dynamic programming section of your course?

NO sir I have not done dynamic programming yet .

Then for now you can leave this probelm cause it’s a Dp problem and until you do it. You won’t get what i will explain. So once do DP. Then you can try this problem.

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.