Doubt in a question

I am trying to solve this question from leetcode.
This is the question…
746. Min Cost Climbing Stairs
I have come up with this recursive approch. Can you tell me what is wrong here, it is showing wrong output.
This is my code…

This is simpler form of my code…

This is also the wrong solution… please tell me where i am wrong

you can either start from the step with index 0, or the step with index 1.
so correct way is

int ret1 = solve(cost,0,n);

        int ret2 = solve(cost,1,n);

        return min(ret1,ret2);

Modified Code

no it got accepted

Thanks…
This is what i modefied the code…
More simpler…got accepetd…

great :+1:
keep learning

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.