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
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.
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
Input: ([25.0, 10.3],)
Expected Output: [False, False]
Explanation: Source example 1: two isolated intervals leave most of the segment clean.
Input: ([0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 12.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 23.5, 24.5, 25.5, 26.5, 27.5, 28.5, 29.5, 30.5, 31.5, 32.5, 33.5, 34.5, 35.5, 36.5, 37.5, 38.5, 39.5, 40.5, 41.5, 42.5, 43.5, 44.5, 45.5, 46.5, 47.5, 48.5, 49.6, 49.5],)
Expected Output: [False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, True]
Explanation: Source example 2: [0, 49] covered, 49.6 leaves the 0.1 gap (49, 49.1), 49.5 closes it on the last point.
Hints
- Multiply every value by 100. Each interval then has integer endpoints between 0 and 5000, and the exact-decimal rule becomes plain integer arithmetic with no rounding questions.
- With integer endpoints, [0, 5000] is fully covered exactly when each of the 5000 unit pieces [k, k + 1] lies inside some interval. Keep a count of how many pieces are still clean.
- Each piece only needs to be marked once. A 'next clean piece' pointer array with path compression lets every new interval jump over pieces that are already contaminated.