Optimal Strategy for a game(DP)

26 Sep 2019

Optimal Strategy For a Game

Problem

You are given an array A of size N. The array contains integers and is of even length. The elements of the array represent N coin of values V1, V2, ….Vn. You play against an opponent in an alternating way.

In each turn, a player selects either the first or last coin from the row, removes it from the row permanently, and receives the value of the coin.

You need to determine the maximum possible amouin4t of money you can win if you go first.

P.S. - Both the players use optimum strategy.

DP Solution - gfg-dp31

Code - here

Take note