Programming Exercises

Create a component that takes a hardcoded array of intervals and merges any overlapping intervals.

Hard

Problem Statement

Create a component that takes a hardcoded array of intervals and merges any overlapping 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
import React from "react"; const MergeIntervals = () => { return ( <div> {/* Display merged intervals */} </div> ); }; export default MergeIntervals;
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]]