FastPrepMerge Intervals
Problems/Merge Intervals

Merge Intervals

SeekOut logoSeekOut● MediumONSITE INTERVIEW
QuestionFunctionExamples

Problem statement

Source note: This problem is backed by a real SeekOut onsite interview report. The report directly named Merge Intervals, but it did not include the exact function interface, examples, constraints, or interval-boundary convention. This judged version uses closed intervals, so the core task match is about 90%.

Given a collection of closed intervals [start, end], merge every pair that overlaps or touches and return the resulting non-overlapping intervals sorted by start.

Function

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

Examples

Example 1

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

Example 2

intervals = [[1,4],[4,5]]return = [[1,5]]
See SeekOut hiring insights
Saved
class Solution {
    public int[][] merge(int[][] intervals) {
      // write your code here
    }
}
Checking account…