You're given a collection of circles on a 2D coordinate grid, and you need to count how many lattice points (points with integer coordinates) fall inside at least one of these circles.
Each circle is defined by its center coordinates (x, y) and radius r. A point is considered inside a circle if the distance from the point to the circle's center is less than or equal to the radius - this means points on the circumference count too!
Goal: Return the total count of unique lattice points that are covered by one or more circles.
Example: If you have a circle centered at (0, 0) with radius 2, it would contain lattice points like (0,0), (1,0), (0,1), (2,0), etc.
Input & Output
Visualization
Time & Space Complexity
Where C is number of circles and R is the maximum radius. We check at most (2R+1)ยฒ points per circle.
Where P is the number of unique lattice points inside circles (for the hash set)
Constraints
- 1 โค circles.length โค 200
- circles[i].length == 3
- 1 โค xi, yi โค 100
- 1 โค ri โค min(xi, yi)
- Important: Points on the circumference are considered inside the circle