strokes[i] = [start, end, color] means the half-open interval [start, end) (including start, excluding end) got paint number color. All paint numbers are distinct.
Where strokes overlap, the paints blend, and the colour of a stretch is the set of every paint lying on it. Instead of the set itself, we record the sum of the paint numbers in it.
Describe the finished strip with the fewest non-overlapping half-open pieces [left, right, mix], where mix is the sum of the paint numbers on [left, right). Neighbouring pieces must stay separate if their sets of paints differ, even when the sums match. Leave unpainted stretches out of the answer.
The pieces may be returned in any order.strokes=[[2, 6, 4], [4, 9, 10]] → [[2, 4, 4], [4, 6, 14], [6, 9, 10]]
Only paint 4 covers [2, 4), paints 4 and 10 mix on [4, 6) (sum 14), and only 10 is left on [6, 9).
strokes=[[1, 3, 7], [5, 8, 2]] → [[1, 3, 7], [5, 8, 2]]
Nothing is painted between 3 and 5, so that part is left out of the answer.
strokes=[[1, 5, 3], [1, 5, 8], [5, 9, 11]] → [[1, 5, 11], [5, 9, 11]]
Both pieces sum to 11, but the sets of paints differ ({3, 8} and {11}), so they cannot be merged into a single [1, 9).
color values are distinctstrokes=[[2, 6, 4], [4, 9, 10]]
[[2, 4, 4], [4, 6, 14], [6, 9, 10]]
Run checks the first 3 tests in your browser. Submit checks all 84 tests on the server, hidden ones included.