Track Received Byte Ranges
Learn this problemProblem statement
A user uploads a large file by sending chunks of consecutive bytes. Each chunks[i] is [left, right], where both values are 64-bit integers and identify an inclusive, 1-based byte range.
After every chunk arrives, consolidate all bytes received so far into disjoint consecutive intervals. Overlapping or adjacent intervals merge, and a chunk may overlap or fully duplicate earlier data.
Return one snapshot for each received chunk. Within a snapshot, intervals are sorted by their left endpoint and each interval is serialized as left:right. Therefore, result[i] is the string array describing all received ranges after processing chunks[i].
Function
trackReceivedByteRanges(chunks: long[][]) → String[][]Examples
Example 1
chunks = [[1,1],[2,2],[3,3]]return = [["1:1"],["1:2"],["1:3"]]Each newly received byte is adjacent to the existing range, so the single interval grows from 1:1 to 1:2 and then 1:3.
Example 2
chunks = [[7,9],[1,3],[8,15],[6,9],[2,4]]return = [["7:9"],["1:3","7:9"],["1:3","7:15"],["1:3","6:15"],["1:4","6:15"]]The third chunk overlaps 7:9, extending it to 7:15. The fourth chunk then extends that interval left to 6:15. The final chunk overlaps 1:3 and extends it to 1:4.
Constraints
- Every
chunks[i]contains exactly two 64-bit integers. - For each chunk,
1 <= chunks[i][0] <= chunks[i][1].
More Capital One problems
- Compare Counts Around PivotOA · Seen Jul 2026
- Format a Newspaper PageOA · Seen Jul 2026
- Laser Robot Safe PathOA · Seen Jul 2026
- Match Consecutive Word BoundariesOA · Seen Jul 2026
- Reconstruct Landmark JourneyOA · Seen Jul 2026
- Rightmost Longest Character RunOA · Seen Jul 2026
- Alternate String EndsOA · Seen Jul 2026
- Round-Robin WDL OrderOA · Seen Jul 2026