This is a verified interview question from Netradyne. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Lattice Points Within a Circle" covers key patterns like Other.
"### PROBLEM IIT You are given a rectangular grid defined by its bottom-left corner (x1, y1) and top-right corner (x2, y2). You are also given a point (xc, yc) and a radius r. Your task is to find all lattice points (x, y) such that: 1. The point lies inside or on the boundary of the rectangle. 2. The Euclidean distance from (x, y) to (xc, yc) is less than or equal to r. ### INPUT Seven integers: x1, y1, x2, y2, xc, yc, r ### OUTPUT Return a list of all lattice points (x, y) satisfying: * x1 ≤ x ≤ x2 * y1 ≤ y ≤ y2 * (x - xc)^2 + (y - yc)^2 ≤ r^2 ### KEY INSIGHT Instead of checking every point in the rectangle, iterate over: x in [xc - r, xc + r] For each x, compute the valid range of y using: (y - yc)^2 ≤ r^2 - (x - xc)^2"
Join thousands of developers practicing for Netradyne.