Smallest Point with Maximum Interval Coverage
Problem statement
Given a nonempty collection of closed integer intervals [left, right], return the smallest integer contained in the largest number of intervals.
An interval contains point when left <= point <= right. Count repeated intervals separately. A point interval [a,a] contains a. When several points have maximum coverage, choose the smallest.
Function
smallestMaximumOverlapPoint(intervals: int[][]) → intExamples
Example 1
intervals = [[2,13],[3,5],[1,4],[2,5]]return = 3Both 3 and 4 lie in all four intervals. The specified smallest-point tie rule chooses 3.
Example 2
intervals = [[1,2],[2,4]]return = 2The intervals share their closed endpoint 2, so its coverage is two.
Example 3
intervals = [[-3,-1],[0,2]]return = -3The maximum coverage is one. The smallest covered integer is -3.
Constraints
1 <= intervals.length <= 1000.- Each row has two integers with
-1000000000 <= left <= right <= 1000000000.