Description
Solutions
Submission
Find Overlapping Times 🍐
🤘 INTERN
A Supply Chain Manager at an Amazon warehouse is reviewing the logs of when trucks arrived at and departed from their warehouse. Please help them with their review by completing the following challenge: Given a collection of time intervals, [start, end], merge and return the overlapping intervals sorted in ascending order of their start times.
Function Description
Complete the function findOverlappingTimes
in the editor.
findOverlappingTimes
has the following parameter(s):
int intervals[[n][2]]
: the time intervals
Returns
int[][2]
: the merged intervals in sorted order
Example 1:
Input: intervals = [[7, 7], [2, 3], [6, 11], [1, 2]]
Output: [[1, 3], [6, 11]]
Explanation:The interval [1, 2] merges with [2, 3] while [7, 7] merges with [6, 11]. There are no more overlapping intervals. The answer is [[1, 3], [6, 11]].
Constraints:
- 1 ≤ n ≤ 105
- 1 ≤ intervals[i][2] ≤ 109
- intervals[i][0] ≤ intervals[i][1] for all i.
Related Problems
Testcase
Result
Case 1
input:
output: