Is the Segment From 0 to 50 Fully Contaminated After Each Landing Point?

Quick Overview

Points land one at a time on the segment from 0 to 50, each contaminating an interval of length 1 around it; after each landing, report whether the whole segment is contaminated. Tests interval union maintenance, exact boundary handling and efficient updates.

Is the Segment From 0 to 50 Fully Contaminated After Each Landing Point?

Company: Waymo

Role: Site Reliability Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Consider the number line segment `[0, 50]`. Points keep landing on it one at a time. Each point contaminates the region within 0.5 of where it lands, that is, an interval of length 1 centered on the point. Once part of the line is contaminated it stays contaminated forever. Points can land anywhere on the segment, and the regions of different points may overlap. The interview asked you to design a function that is called once per landing point (given as a floating-point number) and returns a boolean telling whether the entire segment `[0, 50]` is now contaminated. In this console version you receive all landing points in order and return the answer after each one. ### Function Signature ```python def fully_contaminated_after_each(points: list[float]) -> list[bool]: ``` ### Rules - A point landing at `p` contaminates the closed interval `[p - 0.5, p + 0.5]`, clipped to `[0, 50]`. - The segment is fully contaminated when every real number in `[0, 50]`, including both endpoints, lies in at least one contaminated interval. Two intervals that touch at a single point leave no gap between them. - The `i`-th output is `True` if the segment is fully contaminated after processing `points[0]` through `points[i]`, and `False` otherwise. Once an output is `True`, all later outputs are `True`. - Every landing point has at most two digits after the decimal point. Decide coverage using the exact decimal values as written (for example, `0.35 + 0.5` equals exactly `0.85`), not values affected by floating-point rounding. ### Constraints - `1 <= len(points) <= 10^5` - `0 <= points[i] <= 50` - Each `points[i]` has at most two digits after the decimal point. - Points may repeat. ### Examples **Example 1** - Input: `points = [25.0, 10.3]` - Output: `[False, False]` - Explanation: Only `[24.5, 25.5]` and `[9.8, 10.8]` are contaminated. **Example 2** - Input: `points` is the 49 values `0.5, 1.5, 2.5, ..., 48.5` in increasing order, followed by `49.6`, followed by `49.5` (51 points in total). - Output: 49 values `False`, then `False`, then `True`. - Explanation: The first 49 points contaminate `[0, 49]` exactly. The point `49.6` adds `[49.1, 50]` (clipped at 50), which still leaves the gap between 49 and 49.1. The point `49.5` adds `[49, 50]` and closes it. **Example 3** - Input: `points = [0.2, 49.8]` - Output: `[False, False]` - Explanation: The contaminated intervals `[0, 0.7]` and `[49.3, 50]` cover both ends, but the middle is still clean.

Overview: Points land one at a time on the segment from 0 to 50, each contaminating an interval of length 1 around it; after each landing, report whether the whole segment is contaminated. Tests interval union maintenance, exact boundary handling and efficient updates.

|Home/Coding & Algorithms/Waymo
Waymo logo
Waymo
Sep 10, 2026
mediumSite Reliability EngineerOnsiteCoding & Algorithms
0
0

Consider the number line segment [0, 50]. Points keep landing on it one at a time. Each point contaminates the region within 0.5 of where it lands, that is, an interval of length 1 centered on the point. Once part of the line is contaminated it stays contaminated forever. Points can land anywhere on the segment, and the regions of different points may overlap.

The interview asked you to design a function that is called once per landing point (given as a floating-point number) and returns a boolean telling whether the entire segment [0, 50] is now contaminated. In this console version you receive all landing points in order and return the answer after each one.

Function Signature

def fully_contaminated_after_each(points: list[float]) -> list[bool]:

Rules

  • A point landing at p contaminates the closed interval [p - 0.5, p + 0.5] , clipped to [0, 50] .
  • The segment is fully contaminated when every real number in [0, 50] , including both endpoints, lies in at least one contaminated interval. Two intervals that touch at a single point leave no gap between them.
  • The i -th output is True if the segment is fully contaminated after processing points[0] through points[i] , and False otherwise. Once an output is True , all later outputs are True .
  • Every landing point has at most two digits after the decimal point. Decide coverage using the exact decimal values as written (for example, 0.35 + 0.5 equals exactly 0.85 ), not values affected by floating-point rounding.

Constraints

  • 1 <= len(points) <= 10^5
  • 0 <= points[i] <= 50
  • Each points[i] has at most two digits after the decimal point.
  • Points may repeat.

Examples

Example 1

  • Input: points = [25.0, 10.3]
  • Output: [False, False]
  • Explanation: Only [24.5, 25.5] and [9.8, 10.8] are contaminated.

Example 2

  • Input: points is the 49 values 0.5, 1.5, 2.5, ..., 48.5 in increasing order, followed by 49.6 , followed by 49.5 (51 points in total).
  • Output: 49 values False , then False , then True .
  • Explanation: The first 49 points contaminate [0, 49] exactly. The point 49.6 adds [49.1, 50] (clipped at 50), which still leaves the gap between 49 and 49.1. The point 49.5 adds [49, 50] and closes it.

Example 3

  • Input: points = [0.2, 49.8]
  • Output: [False, False]
  • Explanation: The contaminated intervals [0, 0.7] and [49.3, 50] cover both ends, but the middle is still clean.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...