Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to merge overlapping intervals in a list of intervals.

Hard

Problem Statement

Write a function to merge overlapping intervals in a list of intervals.

Sample Input

[[1, 3], [2, 6], [8, 10], [15, 18]]

Sample Output

Merged Intervals: [ [ 1, 6 ], [ 8, 10 ], [ 15, 18 ] ]

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
function mergeIntervals(intervals: number[][]): number[][] { // Your logic here }
Log in or sign up to run or submit your code.Log inSign up
Input
[[1, 3], [2, 6], [8, 10], [15, 18]]
Expected Output
Merged Intervals: [ [ 1, 6 ], [ 8, 10 ], [ 15, 18 ] ]