Batch Point-in-Range Queries
Updated
Problem statement
You are given closed numeric ranges in ranges and query values in points. Each range is [left, right] and includes both endpoints.
Return a boolean array where result i is true exactly when points[i] lies in at least one range.
Ranges may overlap or touch, and all inputs may contain fractional values. Compare the supplied finite values directly; do not apply an epsilon.
Function
pointsInRanges(ranges: double[][], points: double[]) → boolean[]Examples
Example 1
ranges = [[1.5,3.0],[5.0,7.25]]points = [1.5,4.0,7.25]return = [true,false,true]The first and third values equal closed endpoints, while 4.0 lies in the gap.
Example 2
ranges = [[0.0,2.0],[1.0,4.0],[-2.0,-1.0]]points = [-1.0,0.0,3.5,4.1]return = [true,true,true,false]The overlapping first two ranges cover every value from 0.0 through 4.0. The negative range includes -1.0.
Example 3
ranges = []points = [0.0,-2.5]return = [false,false]No point is covered when there are no ranges.
Constraints
0 <= ranges.length, points.length <= 200000.- Every range contains exactly two finite values and satisfies
ranges[i][0] <= ranges[i][1]. - Every point is finite.
- Every endpoint and point is between
-10^12and10^12.
More Google Phone Screen questions
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Apartment Housemate PreferencesPHONE SCREEN · Seen Nov 2026
- Price at Query TimestampsPHONE SCREEN · Seen Nov 2026
- Course Schedule Cycle DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Classify Heap Addresses from a Memory SnapshotSquarepoint Capital · PHONE SCREENSquarepoint Capital interview questions
- Maximum Profit in Job SchedulingAmazon · PHONE SCREEN
- Maximum Interactive Team SizeMicrosoft · OAMicrosoft interview questions
- Maximum Team SizeExpedia · OAExpedia interview questions
- Employee With the Most OverlapsCitadel · OACitadel interview questions
- 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