Why wont my code work for index n-1,

question
https://hack.codingblocks.com/contests/c/512/369
my code
https://ide.codingblocks.com/s/36406

You jest need to make change in the base case.
It would be n instead of n-1 there.

I have answered it in complete cpp section and also provided link to code which has changes required in your code, there. Take a look at it.