Tap here to switch tabs
Problem
Submissions

Problem: Remove Boxes

med
30 min
Try to solve the Remove Boxes problem.

Statement

You are given an integer array boxes where each element represents the color of a box.

You can perform multiple rounds of box removal until no boxes remain. In each round, you can select a contiguous sequence of kk boxes (k≥1k \geq 1) that all share the same color, remove them, and earn kimeskk imes k points.

Return the maximum total points you can obtain.

Constraints:

  • 1≤1 \leq boxes.length ≤100\leq 100

  • 1≤1 \leq boxes[i] ≤100\leq 100

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Remove Boxes

med
30 min
Try to solve the Remove Boxes problem.

Statement

You are given an integer array boxes where each element represents the color of a box.

You can perform multiple rounds of box removal until no boxes remain. In each round, you can select a contiguous sequence of kk boxes (k≥1k \geq 1) that all share the same color, remove them, and earn kimeskk imes k points.

Return the maximum total points you can obtain.

Constraints:

  • 1≤1 \leq boxes.length ≤100\leq 100

  • 1≤1 \leq boxes[i] ≤100\leq 100