Please help me to correct the code :-
Hello @anshulgurawalia no your appraoch is wrong.
in this we have to minimise the result of the opponent.
because both will choose the maximum two win.
take this example:
take this example:
let us take the example of the test case .
10
22 50 16 13 8 41 25 43 8 7
in this the piyush chooses number are 7+50+13+41+43
and nimit chooses number are 22+16+8+25+8.
and the output for piyush will be 154.
try to understand with this:
please help me in understanding the ques .
if piyush turn will come first first he can either pick the first element or the array for last on the basics of their values but in your test case you piyush choses 7??why? i think it should choose 22 to make its sum maximize .
if he will choose 22 then nimit in the next turn will choose 50 which is way more then that:
so we have to look in this way:
hence we will try to find the local optimal solution solution which will give us the global optimium result.
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.