码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode] Remove Boxes 移除盒子

时间:2017-05-13 23:20:06      阅读:228      评论:0      收藏:0      [点我收藏+]

标签:input   tput   int   sed   inpu   cee   etc   different   box   

 

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 移除盒子

标签:input   tput   int   sed   inpu   cee   etc   different   box   

原文地址:http://www.cnblogs.com/grandyang/p/6850657.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!