Running Union Length after Interval Uploads
Problem statement
Each row [left, right] uploads a continuous half-open interval [left, right) with left < right. Intervals may overlap or touch.
After every upload, return the total length covered by the union of all intervals seen so far.
Function
runningUnionLengths(uploads: long[][]) → long[]Examples
Example 1
uploads = [[1,5],[3,8]]return = [4,7]The second interval adds only its uncovered suffix.
Example 2
uploads = [[1,2],[5,9]]return = [1,5]Disjoint lengths add.
Constraints
1 <= uploads.length <= 2000-10^12 <= left < right <= 10^12