84. Insert Interval
Medium
You are given a sorted list of non-overlapping closed intervals and a new interval. Insert the new interval, merge all overlaps, and return the final list sorted by starting point.
Example 1
Input: intervalos = [[1, 2], [5, 7], [9, 12]], novo = [3, 6]
Output: [[1, 2], [3, 7], [9, 12]]
Example 2
Input: intervalos = [[2, 4], [8, 10]], novo = [4, 8]
Output: [[2, 10]]
Constraints
- 0 <= intervalos.length <= 10^4
- The input intervals are sorted and do not overlap.
- -10^9 <= início <= fim <= 10^9
Intervals
Saved in this browser
Caso 1
intervalos =
[[1,2],[5,7],[9,12]]
novo =
[3,6]
Expected =
[[1,2],[3,7],[9,12]]
Caso 2
intervalos =
[[2,4],[8,10]]
novo =
[4,8]
Expected =
[[2,10]]
Run checks these 2 cases. Submit runs all 6, including hidden ones.