In the Coordinate With Maximum Network Quality coding problem, you are given an array of tower locations and their signal strengths, along with a radius. The network quality at any coordinate (x, y) is the sum of the floor of (strength / (1 + distance)) for all towers within the given radius. You need to find the integer coordinate within a bounded area (0 to 50 for both x and y) that has the maximum network quality. If there's a tie, return the lexicographically smallest coordinate.
Lyft uses the Coordinate With Maximum Network Quality interview question to test your ability to implement a simulation based on specific rules. Since the search space is small (51x51 points), it evaluates whether you can correctly translate a mathematical formula into code and handle tie-breaking conditions. It’s a "Medium" problem that focuses on accuracy and enumeration.
The pattern is Brute Force / Enumeration.
(x, y) where 0 <= x, y <= 50.distance <= radius, calculate the signal contribution: floor(q / (1 + d)).(x, y).(x, y) that yields the maximum sum, following the tie-breaker rule.Tower at (1, 2) with strength 5, Radius 2.
Check coordinate (1, 1):
d = sqrt((1-1)^2 + (2-1)^2) = 1.1 <= 2 (within radius).floor(5 / (1 + 1)) = floor(2.5) = 2.
Check coordinate (5, 5):d = sqrt((5-1)^2 + (5-2)^2) = 5.5 > 2 (outside radius).0.(x, y) in case of multiple maximums.floor of the signal strength correctly.sqrt unnecessarily when comparing distances (it's better to compare d^2 with radius^2 to avoid precision issues).When the constraints are small (like 0 to 50), don't look for a complex mathematical optimization. A clean, bug-free brute force is exactly what the interviewer is looking for.