Math
1 | class Solution { |
Remarks:
- First sort, then combine intervals
- Customize sort:
Arrays.sort(intervals, (a, b) -> Integer.compare(a[0], b[0]));
- TC: $O(n \log n + n) = O(n \log n)$ ($n\log n$ is from sorting), SC: $O(n)$
1 | class Solution { |
Remarks:
Arrays.sort(intervals, (a, b) -> Integer.compare(a[0], b[0]));