Reported April 2026
Scale AIsorting

Free Windows Between Busy Intervals

Reported by candidates from Scale AI's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Scale AI OA. Under 2s to a working solution.
Founder's read

The mistake that sinks a first attempt on this Scale AI question is forgetting to sort before merging. The unsorted input looks harmless until your merge loop spits out gaps that don't exist. Scale AI candidates reported it in April 2026, and it's a classic merge-intervals problem with a twist: you return the holes, not the blocks. Touching intervals like [1,5) and [5,8) must fuse, so a zero-length gap never counts. If you blank on the sort-and-sweep, StealthCoder sits invisibly on your screen during the live OA as a safety net. Know the pattern first, though. It's about ten lines.

The problem

Given occupied time intervals busy, return every positive-length free interval strictly between the earliest occupied start and the latest occupied end.
For this exercise, assume intervals use integer timestamps and are half-open: [start,end). Overlapping or touching occupied intervals form one occupied block. Time before the first occupied block or after the last occupied block is excluded. With fewer than two disjoint occupied blocks, return an empty array.
Return the gaps as [start,end] rows in increasing start order. The supplied schedules have already been read from their input interface; no network calls are required.

Function
freeWindows(busy: int[][]) → int[][]

Examples
Example 1
busy = [[4,7],[1,3],[9,12]]
return = [[3,4],[7,9]]
The occupied blocks are [1,3), [4,7), and [9,12). Their two internal gaps are returned.
Example 2
busy = [[1,5],[2,3],[5,8],[10,11]]
return = [[8,10]]
The nested and touching intervals combine into [1,8). The remaining gap is [8,10).
Example 3
busy = []
return = []
No occupied blocks means there are no bounded internal gaps.

Constraints
For this exercise, assume 0 <= busy.length <= 100000.
Each row has two integers with 0 <= start < end <= 10^9.
The input may be unsorted and may contain duplicate or nested intervals.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Sort the intervals by start. Walk through them while tracking the current block's end. If the next start is strictly greater than that end, you found a gap: push [curEnd, nextStart]. Otherwise extend curEnd to the max of the two ends. That max is the pitfall. Nested intervals like [2,3) inside [1,5) will shrink your end if you just assign instead of taking the max. Use strict greater-than, not greater-or-equal, because touching intervals form one block and a zero-length gap isn't allowed. Empty input and a single block both fall out naturally as an empty result. Complexity is O(n log n) for the sort, O(n) for the sweep, fine for 100000 rows. Duplicates need no special handling. If you freeze mid-assessment, StealthCoder can hand you the sweep as a hedge, but the logic is short enough to own.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Free Windows Between Busy Intervals 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

You've seen the question. Make sure you actually pass Scale AI's OA.

Scale AI reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Free Windows Between Busy Intervals FAQ

What's the trick in Free Windows Between Busy Intervals?+

Sort by start, then sweep while tracking the furthest end seen so far. A gap only exists when the next start is strictly greater than that end. Everything else is merging. The gap list is a byproduct of the merge, so you don't need a second pass.

How hard is this Scale AI OA question really?+

Easy to medium. If you've done merge intervals, it's the same skeleton with the output flipped. The difficulty is edge cases: nested intervals, touching endpoints, duplicates, and empty input. Get those right and it's quick.

Why do touching intervals like [1,5) and [5,8) matter?+

Intervals are half-open, so 5 is free in the first and busy in the second. They join with no hole. If you use start >= end for the gap check, you'll emit a zero-length gap like [5,5], which the problem forbids. Use strictly greater.

What's the most common bug on this problem?+

Setting the current end to the new interval's end instead of the max. With [1,5) followed by nested [2,3), you'd drop the end to 3 and invent a fake gap from 3 to the next start. Always take max(curEnd, end).

How do I prepare for this in 48 hours?+

Write merge intervals from scratch twice, once sorted by start with max-end tracking. Then modify it to emit gaps. Test with unsorted, nested, duplicate, touching, empty, and single-block inputs. That covers everything Scale AI reported in April 2026 for this question.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Scale AI.

OA at Scale AI?
Invisible during screen share
Get it