FastPrepMerge Overlapping Intervals
Problems/Merge Overlapping Intervals

Merge Overlapping Intervals

Meta logoMeta● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Meta phone screen. The report names Merge Intervals. We chose that interval ends count, the output order, what empty input gives, and the limits on the numbers. Our version is about 85% the same as the reported question.

You are given one array intervals of closed intervals. Each interval [start,end] includes both endpoints. The array may be unsorted, and intervals may overlap or repeat.

Merge all overlapping intervals and return the resulting non-overlapping intervals sorted by start. The result must cover exactly the same points as the input. Two intervals sharing an endpoint overlap; a positive gap keeps them separate.

For this exercise, assume an empty input returns an empty array. You may reorder the input, and returning a new array is allowed.

Function

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

Examples

Example 1

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

The first overlapping group combines [1,3] and [2,6] into [1,6]. The other two ranges remain separate.

Example 2

intervals = [[1,4],[4,5],[7,7]]return = [[1,5],[7,7]]

The first two intervals share endpoint 4, so they merge into [1,5]. The one-point interval [7,7] is separate.

Example 3

intervals = [[1,10],[2,3],[1,10]]return = [[1,10]]

Contained intervals and duplicate intervals do not shrink or repeat the covering range [1,10].

Example 4

intervals = []return = []

There are no covered points, so the result is empty.

Constraints

  • For this exercise, assume 0 <= intervals.length <= 2000.
  • Each interval contains exactly two integers with -10^9 <= start <= end <= 10^9.

More Meta Phone Screen questions

  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockPHONE SCREEN · Seen Nov 2026
  • First Element Greater Than KPHONE SCREEN · Seen Nov 2026
  • Count Events in Rolling Minute WindowsPHONE SCREEN · Seen Oct 2026
  • Valid Word AbbreviationPHONE SCREEN · Seen Oct 2026
  • Shortest Path in a Binary MatrixPHONE SCREEN · Seen Sep 2026
  • Deterministic K-Means AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Values Exclusive to the Current UserPHONE SCREEN · Seen Sep 2026
  • First Bad Version in a Monotone ArrayPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Filter, Sort, and Deduplicate Scheduled TasksRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
  • Merge Sorted Squares of Two ArraysWhatNot · PHONE SCREENWhatNot interview questions
  • Top K Frequent ElementsAmazon · OA · PHONE SCREEN
  • Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Merge Weekday and Time IntervalsNextdoor · PHONE SCREENNextdoor interview questions
  • Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
  • Longest Consecutive SequenceJP Morgan Chase · PHONE SCREENJP Morgan Chase interview questions
  • Determine the Winner of Three-Card HandsOpenAI · PHONE SCREENOpenAI interview questions
  • Sort Ones, Twos, and Threes In PlaceAgoda · PHONE SCREEN · ONSITE INTERVIEWAgoda interview questions
  • Top K Frequent Elements with a Recency TiebreakSwiggy · PHONE SCREEN

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta Software Engineer Onsite Questions: 3 Experiences
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
  • Meta Production Engineer Intern Questions: 6 Experiences
All Meta interview questionsSee Meta hiring insights
Saved
class Solution {
    public int[][] mergeIntervals(int[][] intervals) {
        // Write your code here.
    }
}
Checking account…