PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates array traversal and interval-containment reasoning, including handling inclusive endpoints, overlapping intervals, and preservation of original ordering.

  • medium
  • Roblox
  • Coding & Algorithms
  • Machine Learning Engineer

Find Windows Containing a Target

Company: Roblox

Role: Machine Learning Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

You are given a list of windows, where each window is represented as an inclusive integer interval `[start, end]`, and an integer `target`. Return all windows that contain `target`. A window contains `target` if `start <= target <= end`. Requirements: - Preserve the original order of the matching windows. - Endpoints are inclusive. - Windows may overlap. - The input may be empty. Example: Input: ```text windows = [[1, 5], [6, 10], [3, 7], [8, 12]] target = 6 ``` Output: ```text [[6, 10], [3, 7]] ``` Explanation: `6` is contained in `[6, 10]` and `[3, 7]`, but not in `[1, 5]` or `[8, 12]`.

Quick Answer: This question evaluates array traversal and interval-containment reasoning, including handling inclusive endpoints, overlapping intervals, and preservation of original ordering.

You are given a list of windows, where each window is an inclusive integer interval [start, end], and an integer target. Return all windows that contain target. A window contains target if start <= target <= end. Preserve the original order of the matching windows. Windows may overlap, and the input may be empty.

Constraints

  • 0 <= len(windows) <= 100000
  • Each window has exactly 2 integers: [start, end]
  • -1000000000 <= start, end, target <= 1000000000
  • For every window, start <= end

Examples

Input: ([[1, 5], [6, 10], [3, 7], [8, 12]], 6)

Expected Output: [[6, 10], [3, 7]]

Explanation: The target 6 is inside [6, 10] and [3, 7], but not inside [1, 5] or [8, 12].

Input: ([], 4)

Expected Output: []

Explanation: There are no windows to check, so the result is empty.

Input: ([[5, 7], [7, 9], [1, 7], [8, 10]], 7)

Expected Output: [[5, 7], [7, 9], [1, 7]]

Explanation: The target 7 is included when it equals the end or start of a window because endpoints are inclusive.

Input: ([[-5, -1], [-3, 2], [0, 0], [4, 8]], 0)

Expected Output: [[-3, 2], [0, 0]]

Explanation: The target 0 is inside [-3, 2] and [0, 0], but not inside [-5, -1] or [4, 8].

Input: ([[1, 3], [4, 6]], 7)

Expected Output: []

Explanation: The target 7 is not contained in any window.

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

Expected Output: [[2, 2]]

Explanation: A single-point window contains the target when start, end, and target are all equal.

Hints

  1. Each window can be checked independently, so try scanning the list once from left to right.
  2. Remember that the interval endpoints are inclusive: a window matches when start <= target <= end.
Last updated: May 19, 2026

Loading coding console...

PracHub

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

Product

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

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL 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

  • Implement Sliding-Window Rate Limiter - Roblox (medium)
  • Find target-heavy sliding windows - Roblox (medium)
  • Find most frequent call path in logs - Roblox (medium)
  • Track Highest-Earning Experience - Roblox (medium)
  • Find the Most Frequent Log Call - Roblox (easy)