Coins In A Line Iii

Coins In A Line Iii

题目地址

https://www.lintcode.com/problem/coins-in-a-line/ https://zhengyang2015.gitbooks.io/lintcode/coins_in_a_line_iii_396.html

题目描述

There are n coins in a line. Two players take turns to take a coin from one of the ends of the line until there are no more coins left. The player with the larger amount of money wins.

Could you please decide the first player will win or lose?

Example:
Given array A = [3,2,2], return true.
Given array A = [1,2,4], return true.
Given array A = [1,20,4], return false.

代码

Approach #1 DP

Approach #2 DFS

dp[start][end] => [values[start-1], values[end-1]]

Last updated

Was this helpful?