Problem · Math
Cyber Beacon Detection
Learn this problemProblem statement
A network is modeled as every integer-coordinate node inside an axis-aligned rectangle whose bottom-left corner is (x1, y1) and top-right corner is (x2, y2). Both rectangle boundaries are inclusive.
A beacon centered at (beaconX, beaconY) completely illuminates a node when the node's Euclidean distance from the beacon is at most radius.
Return the number of network nodes that are completely illuminated.
Equivalently, count the integer pairs (x, y) that satisfy both rectangle bounds and (x - beaconX)^2 + (y - beaconY)^2 <= radius^2.
Function
countIlluminatedNodes(x1: int, y1: int, x2: int, y2: int, beaconX: int, beaconY: int, radius: int) → longExamples
Example 1
x1 = -2y1 = -2x2 = 2y2 = 2beaconX = 0beaconY = 0radius = 1return = 5The illuminated nodes are the center and its four axis-adjacent neighbors.
Example 2
x1 = 0y1 = 0x2 = 2y2 = 2beaconX = 0beaconY = 0radius = 2return = 6The six points are (0,0), (0,1), (0,2), (1,0), (1,1), and (2,0).
Example 3
x1 = 5y1 = 5x2 = 7y2 = 7beaconX = 0beaconY = 0radius = 2return = 0The rectangle does not intersect the illuminated circle.
Constraints
-10^9 <= x1 <= x2 <= 10^9-10^9 <= y1 <= y2 <= 10^9-10^9 <= beaconX, beaconY <= 10^90 <= radius <= 10^9x2 - x1 <= 2 * 10^5
More Rippling problems
- IPv4 Address ClassificationOA · Seen Aug 2026
- TV Shows Produced During a PeriodOA · Seen Aug 2026
- Filter and Sort Scheduled TasksONSITE INTERVIEW · Seen Jul 2026
- Stateful Log Transform and SearchPHONE SCREEN · Seen Jul 2026
- Delivery Cost TrackerPHONE SCREEN · Seen Jul 2026
- Corporate Card Expense RulesPHONE SCREEN · Seen Jun 2026
- Camel CardsPHONE SCREEN · Seen May 2026
- Article Vote TrackerPHONE SCREEN · Seen May 2026