One Test Case Failed and Please illustrate what is the meaning of "Both Players play optimally "
My Solution-https://ide.codingblocks.com/s/65219
Optimal Game Strategy--I
Wrong Test Case:
4
1 1 9 4
Your output
5
Correct Output
10 (By first Picking 1 and then 9 in second turn).
Basically your code is completely wrong , you are using greedy algorithm here and this is a DP Problem.
You can search this problem by Name “Optimal Strategy for a Game DP”
Hit like if u get it 
1 Like
Sir u r saying its a DP problem then why is it mentioned under the Topic “Recursion”.
In question it is said “Both Players are playing optimally”. what does this actually mean?
Thanks in advance
1 Like
Sir i realized my mistake it is a DP problem I Got it Thankyou, Sir