Preparing your design workspace

Loading the problem and your saved attempt…

Design an Incremental Lattice Coverage Tracker

Model a class that accepts geometric segments and maintains an exact distinct-point count as the input grows to millions of additions.

Design the low-level objects and contracts for a class that accepts coordinate segments and reports the current number of covered points. The motivating example adds the closed segment from(1,1)to(5,1), which covers five points. Explain how the same design handles millions of additions.

For this exercise, assume coordinates are integers in[-10^9,10^9] and each segment is horizontal or vertical, including a single-point segment. Both endpoints are included, either endpoint order is accepted, and coverage means the set of distinct integer-coordinate points on the inserted segments.

Overlaps and horizontal-vertical crossings count a point once. One application creates an initially empty tracker, adds segments sequentially and reads an exact signed64-bit count between additions. Up to one million additions may be accepted; the coordinate distance may be far larger than the number of inputs.

Invalid diagonal or out-of-range inputs are rejected without changing coverage. If an addition cannot be completed because an owned resource is unavailable, report a failure without exposing partial coverage. Exact retries of the same geometric segment do not add duplicate points.

Produce requirements, an object model, focused interfaces and an interaction walkthrough. Keep the large-input requirement in the design: explain realistic update, count-query and storage costs, including crossings between orientations.

Choose and justify a practical resource envelope; there is no supplied memory budget or latency SLA. A focused follow-up asks how the representation and tests scale without enumerating billions of covered points or building a quadratic compressed grid.

Page-backed indexing may be discussed as a transient resource alternative, with ownership and cleanup defined. Do not implement code. Diagonal geometry, deletions, durable crash recovery, distributed services, graphical rendering and concurrent callers are outside scope.