mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-13 11:21:42 +08:00
add leetcode problem-cn part5
This commit is contained in:
43
算法题(国内版)/problem (Chinese)/移除盒子 [remove-boxes].html
Normal file
43
算法题(国内版)/problem (Chinese)/移除盒子 [remove-boxes].html
Normal file
@@ -0,0 +1,43 @@
|
||||
<p>给出一些不同颜色的盒子<meta charset="UTF-8" /> <code>boxes</code> ,盒子的颜色由不同的正数表示。</p>
|
||||
|
||||
<p>你将经过若干轮操作去去掉盒子,直到所有的盒子都去掉为止。每一轮你可以移除具有相同颜色的连续 <code>k</code> 个盒子(<code>k >= 1</code>),这样一轮之后你将得到 <code>k * k</code> 个积分。</p>
|
||||
|
||||
<p>返回 <em>你能获得的最大积分和</em> 。</p>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>示例 1:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>boxes = [1,3,2,2,2,3,4,3,1]
|
||||
<strong>输出:</strong>23
|
||||
<strong>解释:</strong>
|
||||
[1, 3, 2, 2, 2, 3, 4, 3, 1]
|
||||
----> [1, 3, 3, 4, 3, 1] (3*3=9 分)
|
||||
----> [1, 3, 3, 3, 1] (1*1=1 分)
|
||||
----> [1, 1] (3*3=9 分)
|
||||
----> [] (2*2=4 分)
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 2:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>boxes = [1,1,1]
|
||||
<strong>输出:</strong>9
|
||||
</pre>
|
||||
|
||||
<p><strong>示例 3:</strong></p>
|
||||
|
||||
<pre>
|
||||
<strong>输入:</strong>boxes = [1]
|
||||
<strong>输出:</strong>1
|
||||
</pre>
|
||||
|
||||
<p> </p>
|
||||
|
||||
<p><strong>提示:</strong></p>
|
||||
|
||||
<ul>
|
||||
<li><code>1 <= boxes.length <= 100</code></li>
|
||||
<li><code>1 <= boxes[i] <= 100</code></li>
|
||||
</ul>
|
Reference in New Issue
Block a user