Trains the technique from
LeetCode 1695Maximum Erasure ValueThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A picking aisle is a row of bins. bins[i] is the part number stored in bin i, and clearing a bin earns that many points. The same part number may be stored in more than one bin.
A picker clears one contiguous stretch of bins, and the audit only accepts the run when no part number appears twice inside it. Return the largest number of points such a run can earn.
Example 1
Clearing bins 0 through 2 collects part numbers 1, 5 and 4, which are all different, for 10 points. Adding bin 3 would repeat part number 5, so that run is not accepted.
Example 2
No part number appears twice anywhere, so the whole aisle is one accepted run worth 4 + 2 + 7 + 9 = 22 points.
Example 3
Any accepted run holds at most one bin of part number 2 and one of part number 1, so a run such as bins 0 and 1 earns 3 points.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def maximum_unique_subarray(bins: list[int]) -> int:public int maximumUniqueSubarray(int[] bins)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.