Smallest Point with Maximum Inclusive Interval Overlap
Updated
Problem 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.
More Grab Phone Screen questions
Similar questions at other companies
- Merge IntervalsApple · OA · PHONE SCREEN · ONSITE INTERVIEWApple interview questions
- Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions
- Peak Chat Load Across AgentsCresta · PHONE SCREENCresta interview questions
- Meeting Rooms IIeBay · PHONE SCREENeBay interview questions
- Meeting Rooms IIByteDance · PHONE SCREENByteDance interview questions
- Majority Labels over Audio IntervalsNooks · PHONE SCREEN
- Meeting Rooms IIUber · PHONE SCREENUber interview questions
- Merge IntervalsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle interview questions
- Merge Overlapping IntervalsFurtherAI · PHONE SCREEN
- Peak Resource Usage Across Weighted IntervalsTekion · PHONE SCREENTekion interview questions