[LeetCode] Remove Boxes 移除盒子

Posted Grandyang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[LeetCode] Remove Boxes 移除盒子相关的知识,希望对你有一定的参考价值。

 

Given several boxes with different colors represented by different positive numbers. 
You may experience several rounds to remove boxes until there is no box left. Each time you can choose some continuous boxes with the same color (composed of k boxes, k >= 1), remove them and get k*k points.
Find the maximum points you can get.

Example 1:
Input:

[1, 3, 2, 2, 2, 3, 4, 3, 1]

Output:

23

Explanation:

[1, 3, 2, 2, 2, 3, 4, 3, 1] 
----> [1, 3, 3, 4, 3, 1] (3*3=9 points) 
----> [1, 3, 3, 3, 1] (1*1=1 points) 
----> [1, 1] (3*3=9 points) 
----> [] (2*2=4 points)

 

Note: The number of boxes n would not exceed 100.

 

s

 

以上是关于[LeetCode] Remove Boxes 移除盒子的主要内容,如果未能解决你的问题,请参考以下文章

[LeetCode] Remove Boxes

leetcode 546. Remove Boxes

[LeetCode] Remove Boxes 移除盒子

第十周 Leetcode 546. Remove Boxes (HARD) 记忆化搜索

Codeforces 821C Okabe and Boxes

动态规划——Remove Boxes