I went with a sorted list of merged intervals and a running total of covered length.
Clarify the problem constraints and edge cases, then propose an efficient data structure like a balanced interval tree to maintain disjoint covered intervals. Explain how to merge overlapping intervals and check coverage of [0,50] after each insertion, analyzing time and space complexity.
Pro tip: Mention that using a balanced BST (e.g., red-black tree) for intervals gives O(log n) insertion and merging, but also discuss simpler alternatives like a sorted list with binary search, showing awareness of trade-offs.
Confirm that points are floats, contamination is permanent, and coverage means the entire [0,50] is covered. Discuss edge cases like points outside [0,50] or exactly at boundaries.
Select a structure to maintain disjoint covered intervals, such as a balanced interval tree or a sorted list of intervals. Justify the choice based on expected insertion frequency and performance needs.
For a new point p, compute its contaminated interval [p-0.5, p+0.5]. Insert it into the structure, merging with any overlapping or adjacent intervals to maintain disjointness.
After merging, determine if the union of intervals covers [0,50]. This can be done by checking if there is a single interval that spans from ≤0 to ≥50, or by verifying no gaps exist within [0,50].
Discuss time complexity of insertion and coverage check (e.g., O(log n) with balanced tree), space complexity, and potential optimizations or simpler approaches for small n.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.