Loading...
You are given an array intervals where each intervals[i] = [start, end] denotes a closed interval on the number line. The intervals arrive in no particular order.
Return true if any two of them overlap, and false if every pair is disjoint.
Two intervals overlap when they share at least one point, so intervals that merely touch at an endpoint (for example [1, 4] and [4, 5]) do count as overlapping. An interval always shares points with itself, but a single interval on its own has no partner, so a one-element array is never overlapping.
Input: intervals = [[1,3],[6,9]]
Output: false
Explanation: [1,3] ends at 3 and [6,9] begins at 6, so they share no point.
Input: intervals = [[1,4],[4,5]]
Output: true
Explanation: Both intervals contain the point 4, so they overlap.
Input: intervals = [[8,10],[1,9],[15,18]]
Output: true
Explanation: The input is not sorted. [1,9] and [8,10] share the points 8 through 9.
intervals.length ≤104intervals[i].length =2intervals[i][0] ≤ intervals[i][1] ≤105Click "Run" to test with sample cases or "Submit" to run all tests.