Closed Interval Overlap Queries
Updated
Problem statement
You are given an array of closed integer intervals [start, end] and an array of query points.
Return an integer array whose first value is the maximum number of intervals that cover any point. For each query point in input order, append the number of intervals that contain that point.
An interval [start, end] contains a point x when start <= x <= end. Duplicate intervals and duplicate query points are counted independently.
Function
analyzeIntervals(intervals: int[][], queryPoints: int[]) → int[]Examples
Example 1
intervals = [[1,3],[2,5],[5,7]]queryPoints = [1,5,6]return = [2,1,2,1]The maximum overlap is 2. Point 1 is in one interval, endpoint 5 is in two closed intervals, and point 6 is in one.
Example 2
intervals = [[0,0],[0,0],[-2,2],[2,4]]queryPoints = [0,2,5,0]return = [3,3,2,0,3]Both point intervals and [-2,2] cover 0, producing the maximum 3. Closed endpoint 2 belongs to two intervals.
Example 3
intervals = [[-10,-5],[1,2],[4,9]]queryPoints = [-6,0,9]return = [1,1,0,1]The intervals are disjoint, so the maximum overlap is 1. The middle query lies in no interval.
Constraints
1 <= intervals.length <= 2 * 10^50 <= queryPoints.length <= 2 * 10^5intervals[i].length == 2-10^9 <= intervals[i][0] <= intervals[i][1] <= 10^9-10^9 <= queryPoints[i] <= 10^9
More Netflix interview questions
- Timed Cache with Sidecar CleanupPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Score-Rotating Movie PlaylistONSITE INTERVIEW · Seen Sep 2026
- Undo and Redo Command HistoryONSITE INTERVIEW · Seen Aug 2026
- Balanced Tree Node ReportONSITE INTERVIEW · Seen Aug 2026
- Movie Billboard RotationONSITE INTERVIEW · Seen Jul 2026
- Command Undo Data StructureONSITE INTERVIEW · Seen Apr 2026
- Repeated Titles in Viewing HistoryPHONE SCREEN · Seen Sep 2026
- Capacity-Limited Timed CachePHONE SCREEN · Seen Sep 2026
- Convert Sparse Records to a Filled TableOA · Seen Sep 2026
- Sparse Matrix MultiplicationOA · Seen Sep 2026
Similar questions at other companies
- Maximum Interactive Team SizeMicrosoft · OAMicrosoft interview questions
- Query Weekly Store Opening HoursApple · PHONE SCREENApple interview questions
- Minimum Processes to Drop for SynchronizationAmazon · OA
- Maximum Team SizeExpedia · OAExpedia interview questions
- Employee With the Most OverlapsCitadel · OACitadel interview questions
- Batch Point-in-Range QueriesGoogle · PHONE SCREENGoogle interview questions
- Classify Heap Addresses from a Memory SnapshotSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Unexplained Sightings Outside Flight IntervalsMobileCoin · PHONE SCREEN
- Maximum Event Value with an Attendance LimitSnowflake · PHONE SCREENSnowflake interview questions
- Merge Overlapping IntervalsAtlassian · PHONE SCREEN · ONSITE INTERVIEWAtlassian interview questions