Merge Overlapping Intervals
Reported by candidates from Rippling's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The detail that trips people on this Rippling OA, reported in April 2026, is one line: intervals that share an endpoint overlap. So [1,4] and [4,6] collapse into [1,6]. Everything else is the classic merge intervals setup on an unsorted array of up to 10^5 pairs. If you've seen it before, you'll finish fast. If your brain freezes on the sort-then-sweep idea, StealthCoder runs invisibly during the live assessment and gives you the solution as a safety net. Know the shape of this one before you open the invite.
The problem
Given an array intervals, where intervals[i] = [start, end] is a closed interval, merge every pair of intervals that overlaps. Return the non-overlapping merged intervals sorted by ascending start value. Intervals that share an endpoint overlap. For example, [1, 4] and [4, 6] merge into [1, 6]. 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 become [1, 6]. The other two intervals stay separate. Example 2 intervals = [[1,4],[4,5]] return = [[1,5]] The intervals share endpoint 4, so they overlap under the closed-interval rule. Example 3 intervals = [[5,7],[1,10],[2,3]] return = [[1,10]] The interval [1, 10] contains both other intervals, even though the input is not sorted. Constraints 1 <= intervals.length <= 10^5. intervals[i].length == 2. -10^9 <= intervals[i][0] <= intervals[i][1] <= 10^9.
Reported by candidates. Source: FastPrep
Pattern and pitfall
Sort by start, then sweep once. Keep a result list. For each interval, if its start is less than or equal to the last merged end, extend that end to the max of both ends. Otherwise push it as a new interval. The less-than-or-equal is the whole trick here, since closed intervals touching at a point must merge. The common pitfall is using strict less-than and failing Example 2. The second pitfall is setting the end to the current interval's end instead of the max, which breaks on Example 3 where [1,10] swallows [2,3]. Another one: mutating the input while iterating. Complexity is O(n log n) for the sort and O(n) for the sweep. With 10^5 intervals and values up to 10^9, don't try bucket or array tricks. If you blank mid-assessment, StealthCoder is the hedge that reads the problem and hands you the sort-and-sweep.
StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.
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. If you're reading this with an OA window open, you're who this was built for.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as merge intervals. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Rippling's OA.
Rippling reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Merge Overlapping Intervals FAQ
What's the trick in the Rippling merge intervals question?+
Sort by start value, then walk once and compare each interval's start to the last merged end. Merge when start is less than or equal to that end, and take the max of the two ends. The equals case matters because shared endpoints count as overlapping.
How hard is this OA problem really?+
It's a standard medium. The logic is short, around 10 lines once you see it. The difficulty is remembering to sort first and handling touching endpoints and fully contained intervals. Most failures come from edge cases, not from the core idea.
Why does the input need sorting if the examples look ordered?+
Example 3 is [[5,7],[1,10],[2,3]], which is unsorted. Without sorting by start, you'd miss that [1,10] covers the others. Never assume order. Sort a copy or in place, then sweep, and the output comes out ascending by start automatically.
What time complexity should I aim for with 10^5 intervals?+
O(n log n) from the sort, with a linear merge pass after. Anything quadratic, like comparing every pair, will be too slow at 10^5. Extra space is O(n) for the output list, or O(1) beyond output if you merge in place.
How do I prepare for this in 48 hours?+
Write the sort-and-sweep solution from memory two or three times. Then test it on three cases: touching endpoints, a fully contained interval, and a single interval. Also check negative values, since starts can go down to -10^9. That covers nearly every way this fails.