Practice Remove Boxes
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You are 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 (i.e., composed of k boxes, k >= 1), remove them and get k * k points. Return the maximum points you can get.
Source: Remove Boxes on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
boxes = [1,3,2,2,2,3,4,3,1]
Output
23
# Example 2
Input
boxes = [1,1,1]
Output
9
# Example 3
Input
boxes = [1]
Output
1
Constraints
1 <= boxes.length <= 100
1 <= boxes[i] <= 100
Related LeetCode Problems
Practice more problems similar to Remove Boxes.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.