Skip to content

Commit 4ed5720

Browse files
refactor 546
1 parent d92df22 commit 4ed5720

File tree

1 file changed

+1
-26
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+1
-26
lines changed

src/main/java/com/fishercoder/solutions/_546.java

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,10 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 546. Remove Boxes
5-
*
6-
* Given several boxes with different colors represented by different positive numbers.
7-
* You may experience several rounds to remove boxes until there is no box left.
8-
* 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.
9-
* Find the maximum points you can get.
10-
11-
Example 1:
12-
Input:
13-
14-
[1, 3, 2, 2, 2, 3, 4, 3, 1]
15-
Output:
16-
23
17-
18-
Explanation:
19-
[1, 3, 2, 2, 2, 3, 4, 3, 1]
20-
----> [1, 3, 3, 4, 3, 1] (3*3=9 points)
21-
----> [1, 3, 3, 3, 1] (1*1=1 points)
22-
----> [1, 1] (3*3=9 points)
23-
----> [] (2*2=4 points)
24-
Note: The number of boxes n would not exceed 100.
25-
26-
*/
27-
283
public class _546 {
294
public static class Solution1 {
305
/**
316
* credit: https://leetcode.com/articles/remove-boxes/#approach-2-using-dp-with-memorizationaccepted
32-
*
7+
* <p>
338
* For an entry in dp[l][r][k], l represents the starting index of the subarray,
349
* r represents the ending index of the subarray
3510
* and k represents the number of elements similar to the r​th element

0 commit comments

Comments
 (0)