FastPrepMerge Intervals
Problems/Merge Intervals

Merge Intervals

Zscaler logoZscaler● EasyINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report names Merge Intervals but leaves out how interval boundaries work, the output order, and the limits. Our version is about 72% the same as the reported question.

Given an array of closed intervals where intervals[i] = [start_i, end_i], merge every pair of overlapping intervals.

Return the non-overlapping intervals that cover every input interval, sorted by start value. Intervals that share an endpoint are considered overlapping.

Function

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

Examples

Example 1

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

Intervals [1,3] and [2,6] overlap, so they merge into [1,6].

Example 2

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

The intervals share endpoint 4, so they merge.

Example 3

intervals = [[8,10],[1,4],[2,3],[15,18],[6,9],[3,7],[17,20],[12,12]]return = [[1,10],[12,12],[15,20]]

After sorting, the first five intervals form one overlap chain. The point interval remains separate, and the last two intervals merge.

Constraints

  • 1 <= intervals.length <= 10000
  • intervals[i].length == 2
  • 0 <= start_i <= end_i <= 10000

More Zscaler interview questions

  • Rate Limiter with Hourly and Daily Effort QuotasPHONE SCREEN · Seen Jul 2026
  • Merging PalindromesPHONE SCREEN · Seen Sep 2024
  • Find the Element With Odd FrequencyPHONE SCREEN · Seen Jun 2024
  • Sum of Divisors of the Array GCDPHONE SCREEN · Seen Jun 2024
  • Asteroid CollisionONSITE INTERVIEW · Seen Sep 2024
  • Check Whether a Byte Is NonzeroONSITE INTERVIEW · Seen Sep 2024
  • Count Vowel PermutationsONSITE INTERVIEW · Seen Sep 2024
  • Longest Common Subsequence LengthONSITE INTERVIEW · Seen Jun 2024
  • Run-Length EncodingONSITE INTERVIEW · Seen Jun 2024
  • How Many Sentences? 🌿OA · Seen Mar 2024

Similar questions at other companies

  • Total Years of Work ExperienceLinkedIn · PHONE SCREENLinkedIn interview questions
  • Meeting RoomsByteDance · PHONE SCREENByteDance interview questions
  • Meeting RoomsGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • Merge IntervalsAmazon · OA · PHONE SCREEN · ONSITE INTERVIEW
  • Minimum Number of ChairsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
  • Meeting Room Request FeasibilityApple · PHONE SCREENApple interview questions
  • Meeting RoomsChainalysis · PHONE SCREENChainalysis interview questions
  • Highlight and Rank Overlapping CitationsHarvey · PHONE SCREEN · ONSITE INTERVIEWHarvey interview questions
  • Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
  • Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions

Interview reports that mention this question

  • Zscaler SDE C++ and OS Rounds: 7 Experiences (Part 2 of 6)
  • Zscaler Campus SDE Interviews: 37 Experiences (Part 1 of 6)

Zscaler interview experiences

  • Zscaler Campus Drive Interviews: 4 Experiences (Part 6 of 6)
  • Zscaler Java, QA and Cloud Rounds: 8 Experiences (Part 5 of 6)
  • Zscaler UI and DevTest Rounds: 8 Experiences (Part 4 of 6)
  • Zscaler Intern, QA and SRE Rounds: 7 Experiences (Part 3 of 6)
All Zscaler interview questionsSee Zscaler hiring insights
Saved
class Solution {
    public int[][] mergeIntervals(int[][] intervals) {
      // write your code here
    }
}
Checking account…