Skip to content

Practice Coordinate With Maximum Network Quality

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1620
LeetCode Problem

Coordinate With Maximum Network Quality

Problem Statement

You are given an array of network towers towers, where towers[i] = [xi, yi, qi] denotes the ith network tower with location (xi, yi) and quality factor qi. All the coordinates are integral coordinates on the X-Y plane, and the distance between the two coordinates is the Euclidean distance. You are also given an integer radius where a tower is reachable if the distance is less than or equal to radius. Outside that distance, the signal becomes garbled, and the tower is not reachable. The signal quality of the ith tower at a coordinate (x, y) is calculated with the formula ⌊qi / (1 + d)⌋, where d is the distance between the tower and the coordinate. The network quality at a coordinate is the sum of the signal qualities from all the reachable towers. Return the array [cx, cy] representing the integral coordinate (cx, cy) where the network quality is maximum. If there are multiple coordinates with the same network quality, return the lexicographically minimum non-negative coordinate.

Source: Coordinate With Maximum Network Quality on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
towers = [[1,2,5],[2,1,7],[3,1,9]], radius = 2
Output
[2,1]

# Example 2

Input
towers = [[23,11,21]], radius = 9
Output
[23,11]

# Example 3

Input
towers = [[1,2,13],[2,1,7],[0,1,9]], radius = 2
Output
[1,2]

Constraints

1 <= towers.length <= 50
towers[i].length == 3
0 <= xi, yi, qi <= 50
1 <= radius <= 50

Related LeetCode Problems

Practice more problems similar to Coordinate With Maximum Network Quality.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.