Question:
Given 3n numbers placed in a circle, you and two of your friends are playing a game. Each time you pick a number first, then the two neighboring numbers of the one you picked are picked by your friends. All the picked numbers are removed from the circle and the left numbers compose a new circle. This game terminates when all the numbers are removed.
Write a program to find the maximum sum of the numbers you picked.
Eg, if nums = {1,2,3}, it returns 3
if nums = {1,2,3,4,5,6}, the first run you choose 6 and your friends choose 5 and 1. then nums = {2,3,4}. The 2nd run you choose 4. Thus, it returns 4+6=10;
Problem: How to write a DP solution?
Ref
[1] http://www.mitbbs.com/article_t1/JobHunting/32961687_0_1.html
Given 3n numbers placed in a circle, you and two of your friends are playing a game. Each time you pick a number first, then the two neighboring numbers of the one you picked are picked by your friends. All the picked numbers are removed from the circle and the left numbers compose a new circle. This game terminates when all the numbers are removed.
Write a program to find the maximum sum of the numbers you picked.
Eg, if nums = {1,2,3}, it returns 3
if nums = {1,2,3,4,5,6}, the first run you choose 6 and your friends choose 5 and 1. then nums = {2,3,4}. The 2nd run you choose 4. Thus, it returns 4+6=10;
Problem: How to write a DP solution?
Ref
[1] http://www.mitbbs.com/article_t1/JobHunting/32961687_0_1.html
No comments:
Post a Comment