FastPrepMerge Overlapping Intervals
Problems/Merge Overlapping Intervals

Merge Overlapping Intervals

Fox Corporation logoFox Corporation● MediumFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: The reported task identifies this standard algorithmic exercise. The executable interface, bounds, deterministic tie rules, and examples are the documented practice contract.

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.

More Fox Corporation problems

  • S-Shaped Matrix TraversalPHONE SCREEN · Seen Sep 2026
  • Count Communicating ServersPHONE SCREEN · Seen Sep 2026
  • Find a Peak ElementPHONE SCREEN · Seen Sep 2026
See Fox Corporation hiring insights
Saved
class Solution {
    public int[][] mergeIntervals(int[][] intervals) {
        // Merge all overlapping closed intervals.
    }
}
Checking account…