Track Received Byte Ranges
Reported by candidates from Roblox's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Byte offsets run up to 10^18, so any approach that marks individual bytes is dead on arrival. That's the first thing to clock in this Roblox OA, reported in September 2026. You get a stream of inclusive ranges and must output a merged snapshot after every arrival. It's a merge-intervals problem dressed up as a file upload tracker, with one twist: adjacent ranges merge too. If you blank on the details during the live assessment, StealthCoder runs invisibly as a safety net and gives you a working solution while you keep your head. Here's the script.
The problem
A file is uploaded as a sequence of byte-range chunks. Each chunks[i] is an inclusive, 1-based range [start, end]. After each chunk arrives, consolidate every byte received so far into disjoint consecutive ranges. Overlapping or adjacent ranges merge. For example, [1, 3] and [4, 6] merge because 4 <= 3 + 1. Return one snapshot after each arrival. Within each snapshot, sort ranges by their left endpoint and serialize each range as start:end. Function trackReceivedByteRanges(chunks: long[][]) → String[][] Examples Example 1 chunks = [[1,3],[4,6]] return = [["1:3"],["1:6"]] After the first arrival the received range is 1:3. The second chunk is adjacent, so the ranges merge into 1:6. Example 2 chunks = [[8,10],[1,2],[2,8],[4,5]] return = [["8:10"],["1:2","8:10"],["1:10"],["1:10"]] The third chunk connects and overlaps both existing ranges, producing 1:10. The final contained chunk leaves that range unchanged. Constraints 1 <= chunks.length <= 2000. Every chunks[i] contains exactly two signed 64-bit integers. 1 <= chunks[i][0] <= chunks[i][1] <= 10^18. Duplicate and fully contained chunks are valid and do not change the consolidated ranges.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is to treat ranges, never bytes. Keep a sorted list of disjoint intervals. For each new chunk, find every existing interval that overlaps or touches it, meaning existing.start <= new.end + 1 and existing.end >= new.start - 1. Merge them into one by taking the min start and max end, then insert the result in order. With n up to 2000, rebuilding the list on each arrival is O(n) per step and O(n^2) overall, which is plenty fast. The pitfalls are the adjacency rule (4 <= 3 + 1), and overflow. Values reach 10^18, so end + 1 is fine in signed 64-bit, but don't multiply or sum two endpoints. Also remember each snapshot is a fresh copy, not a reference to a list you keep mutating. StealthCoder is your hedge if the off-by-one logic slips live.
If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.
You can drill Track Received Byte Ranges cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as data stream as disjoint intervals. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Roblox's OA.
Roblox reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Track Received Byte Ranges FAQ
What's the core trick in Track Received Byte Ranges?+
Store disjoint sorted intervals, never individual bytes. For each new chunk, absorb every interval that overlaps or is adjacent (start <= newEnd + 1 and end >= newStart - 1), then insert the merged interval. Serialize a copy as start:end strings after each arrival.
Why can't I use a boolean array or set of bytes?+
Endpoints go up to 10^18, so you can't allocate or iterate over that many bytes. The input has at most 2000 chunks, so the solution has to scale with the number of ranges, not the byte positions.
Do adjacent ranges really merge?+
Yes. The statement says [1,3] and [4,6] merge because 4 <= 3 + 1. So your overlap check must include touching ranges, not just strictly overlapping ones. Missing that gives wrong output on Example 1.
Is O(n^2) fast enough here?+
With chunks.length up to 2000, rebuilding or scanning a list of at most 2000 intervals on each arrival is about 4 million operations. That's fine. You don't need a balanced tree or ordered map unless you want one.
How do I prepare for this in 48 hours?+
Write the classic merge intervals solution, then modify it to insert one interval at a time into a sorted list with the adjacency rule. Test duplicates, fully contained chunks, and a chunk that bridges two ranges, like Example 2. Use 64-bit types and copy each snapshot.