Quick Overview

This question evaluates understanding of sorted array manipulation, interval arithmetic, detection of maximal missing ranges, and careful handling of boundary and edge cases in integer intervals.

Find Missing Ranges with Bounds

Company: Bytedance

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Technical Screen

Given a sorted array of distinct integers `nums` and two integers `lower` and `upper` that define an inclusive interval `[lower, upper]`, return all maximal ranges of integers inside `[lower, upper]` that do not appear in `nums`. Ignore any values in `nums` that fall outside the interval. Represent each missing range as: - `[x]` if exactly one number is missing - `[start, end]` if multiple consecutive numbers are missing Example: - Input: `nums = [3, 5, 10]`, `lower = 0`, `upper = 9` - Output: `[[0, 2], [4], [6, 9]]` Return the missing ranges in ascending order.

Quick Answer: This question evaluates understanding of sorted array manipulation, interval arithmetic, detection of maximal missing ranges, and careful handling of boundary and edge cases in integer intervals.

Return all maximal missing integer ranges inside [lower, upper], using [x] for singletons.

Constraints

  • Inputs are Python literals matching the function signature.
  • Return a deterministic exact-match value.

Examples

Input: ([3,5,10], 0, 9)

Expected Output: [[0, 2], [4], [6, 9]]

Explanation: Missing ranges are inside the inclusive bounds.

Input: ([], 1, 3)

Expected Output: [[1, 3]]

Explanation: All values in the range are missing.

Hints

  1. Clarify edge cases before coding.
  2. Keep outputs deterministic when several valid answers exist.

Loading coding console...