As reported: Expedia SDE3 (GenAI/ML) screening / elimination round, one hour, coding focused (India, 2026): Merge Overlapping Intervals, then Number of Islands. Comparing only adjacent pairs without the sort-and-merge-with-the-last-interval idea did not converge. Also asked as the first of two problems in an Expedia Senior Software Engineer technical screen (60 minutes with an engineer, 2026), solved quickly with its complexity.
Given an array intervals with intervals[i] = [start, end], merge all overlapping intervals and return the resulting non-overlapping intervals.
This is LeetCode 56 — Merge Intervals.
Example
[[1,3],[2,6],[8,10],[15,18]] -> [[1,6],[8,10],[15,18]]
[[1,4],[4,5]] -> [[1,5]]
Constraints: 1 ≤ intervals.length ≤ 10^4; 0 ≤ start ≤ end ≤ 10^4.
Code runner format: one line with intervals. Implement merge(intervals); any order of the result is accepted (the harness sorts it).