FastPrepMerge Intervals
Problems/Merge Intervals

Merge Intervals

OneTrust logoOneTrust● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a first-round OneTrust phone screen for a full-time role. The report names a Merge Intervals question. We reused the function signature, examples, and limits from an equivalent reviewed version.

Our version is about 95% the same as the reported question.

Given an array of closed integer intervals intervals, where each interval is [start, end], merge every pair of overlapping intervals.

Closed intervals that touch at one endpoint overlap. Return disjoint intervals that represent the same union, sorted by increasing start value.

Function

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

Examples

Example 1

intervals = [[1,3],[2,6],[8,10],[10,18]]return = [[1,6],[8,18]]

Intervals [1,3] and [2,6] overlap. Intervals [8,10] and [10,18] touch at endpoint 10, so they also merge.

Example 2

intervals = []return = []

An empty input has an empty union.

Constraints

  • 0 <= intervals.length <= 200000
  • Every row of intervals has exactly two integers [start, end].
  • -10^9 <= start <= end <= 10^9

More OneTrust interview questions

  • Summarize the Latest Event for Each DevicePHONE SCREEN · Seen Sep 2026
  • Keep the First Key for Each Distinct ValueONSITE INTERVIEW · Seen Sep 2026
  • Kth Largest Element in an ArrayONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Merge IntervalsApple · OA · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
  • Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
  • Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
  • Meeting Rooms IIByteDance · PHONE SCREENByteDance interview questions
  • Majority Labels over Audio IntervalsNooks · PHONE SCREEN
  • Meeting Rooms IIUber · PHONE SCREENUber interview questions
  • Merge IntervalsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Merge Overlapping IntervalsFurtherAI · PHONE SCREEN
  • Peak Resource Usage Across Weighted IntervalsTekion · PHONE SCREENTekion interview questions
See OneTrust hiring insights
Saved
class Solution {
    public int[][] mergeIntervals(int[][] intervals) {
        // write your code here
    }
}
Checking account…