PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

Find every non-empty intersection between two sorted lists of disjoint closed intervals. Preserve ascending order and correctly include intersections where intervals meet at a single endpoint.

  • medium
  • Nuro
  • Coding & Algorithms
  • Software Engineer

Find Intersections Between Two Interval Lists

Company: Nuro

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

# Find Intersections Between Two Interval Lists Implement `interval_intersections(first, second)`. `first` and `second` are lists of closed integer intervals `[start, end]`. Within each list, intervals are pairwise disjoint and sorted by start. Return every non-empty intersection between an interval in `first` and an interval in `second`, in ascending order. Because intervals are closed, two intervals that meet at one endpoint intersect at that single point. ## Example ```text first = [[0, 2], [5, 10], [13, 23], [24, 25]] second = [[1, 5], [8, 12], [15, 24], [25, 26]] ``` Return: ```text [[1, 2], [5, 5], [8, 10], [15, 23], [24, 24], [25, 25]] ``` ## Constraints - `0 <= len(first), len(second) <= 100_000` - `-10**9 <= start <= end <= 10**9` - Each input list is sorted and internally pairwise disjoint.

Quick Answer: Find every non-empty intersection between two sorted lists of disjoint closed intervals. Preserve ascending order and correctly include intersections where intervals meet at a single endpoint.

Implement interval_intersections(first, second). Each input is a start-sorted list of pairwise disjoint closed integer intervals [start, end]. Return every non-empty cross-list intersection in ascending order; touching endpoints form a one-point intersection.

Constraints

  • 0 <= len(first), len(second) <= 100,000
  • -10^9 <= start <= end <= 10^9
  • Each list is sorted and internally disjoint.

Examples

Input: ([], [])

Expected Output: []

Explanation: Checks empty, touching, nested, and separated intervals.

Input: ([[0, 2]], [])

Expected Output: []

Explanation: Checks empty, touching, nested, and separated intervals.

Hints

  1. Compare one interval from each list at a time.
  2. After checking an overlap, advance the interval that ends first.
Last updated: Jul 18, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Generate Weighted Random Keys With Add And Remove - Nuro (medium)
  • Reveal a Minesweeper Board - Nuro (medium)
  • Map Weighted Random Draws to Indices - Nuro (medium)
  • Parse logs and count error codes - Nuro (easy)