Target Interval Conflict
Updated
Problem statement
You are given a target half-open interval [target[0], target[1]) and an unsorted collection of half-open intervals intervals. Return true if the target conflicts with at least one interval. Otherwise, return false.
Two half-open intervals conflict when they share at least one point. Endpoints that only touch are not a conflict. Equivalently, [aStart, aEnd) and [bStart, bEnd) do not conflict when aEnd <= bStart or bEnd <= aStart.
This is a single query. The input does not need to be sorted.
Function
hasIntervalConflict(target: int[], intervals: int[][]) → booleanExamples
Example 1
target = [4,8]intervals = [[8,10],[1,4],[6,7]]return = trueThe intervals [1,4) and [8,10) only touch the target at an endpoint, but [6,7) shares points with [4,8).
Example 2
target = [4,8]intervals = [[10,12],[1,4],[8,10]]return = falseEvery interval is disjoint from the target. In particular, [1,4) ends when the target begins, and [8,10) begins when the target ends.
Constraints
target.length == 2.- Every row of
intervalshas length2. - Every target and collection interval is valid:
start < end. intervalsmay be empty and may appear in any order.
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
- Total Years of Work ExperienceLinkedIn · PHONE SCREENLinkedIn interview questions
- Meeting RoomsByteDance · PHONE SCREENByteDance interview questions
- Meeting RoomsGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
- Meeting Room Request FeasibilityApple · PHONE SCREENApple interview questions
- Meeting RoomsChainalysis · PHONE SCREENChainalysis interview questions
- Find First Common AvailabilityDatadog · PHONE SCREENDatadog 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
- Majority Labels over Audio IntervalsNooks · PHONE SCREEN