Describe the Painting
There is a long and thin painting that can be represented by a number line. The painting was painted with multiple overlapping segments where each segment was painted with a unique color.
You are given a 2D integer array segments, where segments[i] = [starti, endi, colori] represents the half-closed segment [starti, endi) with colori as the color.
The colors in overlapping segments were mixed when the painting was made. When two or more colors mix, they form a new color represented as a set of mixed colors. For simplicity, you should output only the sum of the elements in the set rather than the full set.
Describe the finished painting with the minimum number of non-overlapping half-closed segments of these mixed colors. Return a 2D array painting where painting[j] = [leftj, rightj, mixj] describes a half-closed segment [leftj, rightj) with mixed color sum mixj.
Exclude any parts that are not painted. You may return the segments in any order.
A half-closed segment [a, b) is the section of the number line between points a and b, including point a and not including point b.
segments = [[1,4,5],[4,7,7],[1,7,9]][[1,4,14],[4,7,16]]segments = [[1,7,9],[6,8,15],[8,10,7]][[1,6,9],[6,7,24],[7,8,15],[8,10,7]]Constraints
- 1 <= segments.length <= 2 * 10^4
- segments[i].length == 3
- 1 <= starti < endi <= 10^5
- 1 <= colori <= 10^9
- Each colori is distinct.