Problem · Array
Smallest Point with Maximum Inclusive Interval Overlap
Learn this problemProblem statement
Given a nonempty array of inclusive integer intervals [left, right], return the smallest integer point contained in the maximum number of intervals.
An interval contains x when left <= x <= right. Endpoints may be any signed 32-bit integer, including Integer.MAX_VALUE.
Function
smallestMaximumOverlapPoint(intervals: int[][]) → intExamples
Example 1
intervals = [[1,4],[2,5],[4,6]]return = 4Point 4 belongs to all three intervals.
Example 2
intervals = [[-3,-1],[0,2]]return = -3The maximum overlap is one everywhere in the intervals, so the smallest covered point is -3.
Constraints
1 <= intervals.length <= 100000.- Each row contains exactly two integers
left <= right. - Endpoints are in the full signed 32-bit range.