You are given the center and radius of a circle. You are also given the bottom left and top right coordinates of a rectangular grid. You want to find how many points with integer coordinates in the gr
Problem
You are given the center (x, y) and radius r of a circle. You are also given the bottom-left (x1, y1) and top-right (x2, y2) coordinates of a rectangular grid. Your task is to find an efficient algorithm to count how many points with integer coordinates within the grid also lie inside or on the boundary of the circle.
AI interview prep
Core dilemma
Balancing brute-force enumeration of grid points against geometric optimization for counting points within a circular boundary.
2 tradeoffs and 2 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
You are given the center and radius of a circle. You are also given the bottom left and top right coordinates of a rectangular grid. You want to find how many points with integer coordinates in the gr
Problem
You are given the center (x, y) and radius r of a circle. You are also given the bottom-left (x1, y1) and top-right (x2, y2) coordinates of a rectangular grid. Your task is to find an efficient algorithm to count how many points with integer coordinates within the grid also lie inside or on the boundary of the circle.