Intersect Two Sorted Interval Lists
Updated
Problem statement
You are given two lists of closed integer intervals, firstList and secondList. Within each list, intervals are sorted by start and pairwise disjoint.
Return every nonempty intersection between one interval from firstList and one interval from secondList, ordered by increasing start. A shared endpoint is a valid one-point intersection.
Function
intersectIntervalLists(firstList: int[][], secondList: int[][]) → int[][]Examples
Example 1
firstList = [[0,2],[5,10],[13,23],[24,25]]secondList = [[1,5],[8,12],[15,24],[25,26]]return = [[1,2],[5,5],[8,10],[15,23],[24,24],[25,25]]Each result is the closed overlap of the current intervals. Endpoint-only overlaps such as [5,5] are retained.
Example 2
firstList = [[1,3],[6,8]]secondList = [[4,5],[9,10]]return = []No interval in one list overlaps an interval in the other.
Example 3
firstList = []secondList = [[2,7]]return = []An empty list has no intersections.
Constraints
0 <= firstList.length, secondList.length <= 100000.- Every interval has exactly two signed 32-bit endpoints
[start, end]withstart <= end. - Within each list, intervals are sorted by start and satisfy
intervals[i][1] < intervals[i + 1][0].
More ByteDance Phone Screen questions
- Count N-Queens PlacementsPHONE SCREEN · Seen Nov 2026
- Matrix EscapePHONE SCREEN · Seen Nov 2026
- Largest Number Below N from Reusable DigitsPHONE SCREEN · Seen Nov 2026
- Log Analyzer: Busiest Service in a Rolling WindowPHONE SCREEN · Seen Nov 2026
- Majority ElementPHONE SCREEN · Seen Nov 2026
- Valid ParenthesesPHONE SCREEN · Seen Nov 2026
- Binary Tree Target-Sum PathsPHONE SCREEN · Seen Nov 2026
- Longest Increasing SubsequencePHONE SCREEN · Seen Nov 2026
- Alien DictionaryPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lexicographically Smallest Topological OrderPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Meeting Rooms IIUber · PHONE SCREENUber interview questions
- Meeting Rooms IIAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Common Camera Motion IntervalsVerkada · PHONE SCREENVerkada interview questions
- Meeting Rooms IIWalmart · PHONE SCREENWalmart interview questions
- Intersect Two Interval ListsSuperhuman · PHONE SCREENSuperhuman interview questions
- Find Shared Camera Activity PeriodsServal · PHONE SCREEN
- Earliest Common Meeting SlotAdobe · PHONE SCREENAdobe interview questions
- Intersections of Two Interval ListsDatadog · PHONE SCREENDatadog interview questions
- Interval List IntersectionsGoogle · ONSITE INTERVIEWGoogle interview questions
- Most Employees Working at OnceCitadel · OACitadel interview questions
ByteDance interview experiences
- ByteDance TikTok USDS SWE Intern Interview: 1 Experience
- ByteDance MLE New Grad Interviews: 1 Experience
- ByteDance Security SRE Intern Phone Screens: 1 Experience
- ByteDance USDS New Grad SWE Phone Screen: 1 Experience
- ByteDance New Grad Data Engineer Video Interviews: 1 Experience
- ByteDance Trust & Safety Research Scientist Intern: 1 Experience