1 解题思想
开学了,我又回归了。
这道题的意思是给了一个数组,两个人玩,每个人可以在当前的数组的头部或者尾部选择一个数,作为自己的分数,然后换人,已经被选过的数字不能再用。
现在有两个人玩,Player1和Player2,问给了当前的数组后,Player1能不能保证胜利?
解题方法,就是需要做一个决策,看Player1有没有一个必胜的选择决策,这个只需要递归下去选就好。
所谓的必胜,就是当前选到的分数,大于对手能选择到的。
2 原题
Given an array of scores that are non-negative integers. Player 1 picks one of the numbers from either end of the array followed by the player 2 and then player 1 and so on. Each time a player picks a number, that number