Optimal Game Strategy-I

test case 1 giving wrong ans, other two are correct, please help me

don’t use greedy approach.
e.g: 8 10 3 4
1 move -> ans=8
2-> 10
3 -> ans=12
4 -> 3
so the tot ans=12
but o/p will be 14

1-> ans=4
2-> 8
3 -> ans=10+4=14
4 -> 3

so the greedy approach may not work always.

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.