Leetcode - Arrays | Intervals
56. Merge Intervals[M]
https://leetcode.com/problems/merge-intervals/
Description
Given a collection of intervals, merge all overlapping intervals.
Example 1:
1 | Input: [[1,3],[2,6],[8,10],[15,18]] |
Example 2:
1 | Input: [[1,4],[4,5]] |
Solution
https://leetcode.com/problems/merge-intervals/solution/
1 |
57. Insert Interval[H]
https://leetcode.com/problems/insert-interval/
Description
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).
You may assume that the intervals were initially sorted according to their start times.
Example 1:
1 | Input: intervals = [[1,3],[6,9]], newInterval = [2,5] |
Example 2:
1 | Input: intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8] |
NOTE: input types have been changed on April 15, 2019. Please reset to default code definition to get new method signature.
Solution
1 |
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment





