Problem List
Log in
Description
Submissions
Solution
Description
Submissions
Solution
Loading...
Testcase
Test Result
Log in
to run or submit
Case 1
Case 2
intervals =
[[1,3],[6,9]]
newInterval =
[2,5]
Solution
Updated: 2026-02-23
Idea
Add interval into sorted non-overlapping list and merge overlaps.
Approach
Add all intervals ending before new interval starts.
Merge all overlapping intervals into
[s,e]
.
Append the merged interval.
Append the remaining intervals.
Code
JavaScript
Python 3
Java
C#
Loading...
Complexity
Time: O(n)
Space: O(n)
Solution
Updated: 2026-02-23
Idea
Add interval into sorted non-overlapping list and merge overlaps.
Approach
Add all intervals ending before new interval starts.
Merge all overlapping intervals into
[s,e]
.
Append the merged interval.
Append the remaining intervals.
Code
JavaScript
Python 3
Java
C#
Loading...
Complexity
Time: O(n)
Space: O(n)