Reported September 2026
Fox Corporationsorting

Merge Overlapping Intervals

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

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

The Fox Corporation OA, reported in September 2026, hands you merge overlapping intervals, and the trap is the touching endpoint. [1,4] and [4,5] must collapse into [1,5], and a lazy strict less-than check leaves them split. It's an array problem with a sort at the front, and it shows up constantly. Most people know the idea and still fail a hidden test on a boundary or an empty input. If you've got an invite and 48 hours, learn the sort-then-sweep shape cold. StealthCoder sits invisibly on your screen during the live OA as a safety net if your mind goes blank on the details.

The problem

Given a list of closed integer intervals, merge every pair that overlaps and return the disjoint merged intervals ordered by start coordinate.
Closed intervals that share an endpoint overlap, so [1,4] and [4,5] merge into [1,5].

Function
mergeIntervals(intervals: int[][]) → int[][]

Examples
Example 1
intervals = [[1,3],[2,6],[8,10],[15,18]]
return = [[1,6],[8,10],[15,18]]
The first two intervals overlap and merge.
Example 2
intervals = [[1,4],[4,5]]
return = [[1,5]]
Closed intervals sharing endpoint 4 overlap.

Constraints
0 <= intervals.length <= 100000.
Every interval has exactly two values and -10^9 <= start <= end <= 10^9.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Sort the intervals by start. Then sweep once, keeping the last merged interval. If the next start is less than or equal to the last end, they overlap, so set the last end to the max of both ends. Otherwise push a new interval. The less-than-or-equal is the whole edge case, because closed intervals sharing an endpoint merge. The second pitfall is using the new end instead of the max, which breaks when one interval fully contains another, like [1,10] then [2,3]. Also handle an empty list by returning an empty array, and don't mutate shared references if you copy. Sorting costs O(n log n) with n up to 100000, which is fine. If you freeze mid-OA, StealthCoder can feed you the clean sweep so you only have to type it and check the boundaries.

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 Merge Overlapping 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

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as merge intervals. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Fox Corporation's OA.

Fox Corporation 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.

Merge Overlapping Intervals FAQ

What's the trick in the Fox Corporation merge intervals question?+

Sort by start, then sweep once. Merge when the next start is less than or equal to the current end. That equal sign handles closed intervals like [1,4] and [4,5]. Update the end with the max, not the latest end, so contained intervals don't shrink your result.

How hard is this problem really?+

It's a medium on paper but easy once you've seen it. The logic is about ten lines. Candidates lose points on edge cases: touching endpoints, nested intervals, empty input, and unsorted input. Get those four right and you pass the hidden tests.

What edge cases should I test before submitting?+

Test an empty list, a single interval, touching endpoints like [1,4],[4,5], a nested pair like [1,10],[2,3], unsorted input, and negative values up to -10^9. Also run all intervals overlapping into one. Those cover nearly every hidden test for this problem.

What's the time complexity I should aim for?+

O(n log n) from sorting, plus O(n) for the sweep, with n up to 100000. Don't compare every pair, since that's O(n^2) and risks timing out. Extra space is O(n) for the output, or O(log n) beyond it depending on your sort.

How do I prepare for this in 48 hours?+

Write the sort-and-sweep solution from memory three times in your OA language. Use a custom comparator on start values and avoid subtraction overflow tricks. Then run the edge cases above. Also glance at the related insert-interval variant, since the same pattern shows up in it.

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

OA at Fox Corporation?
Invisible during screen share
Get it