You are given a 2D integer array
towers, wheretowers[i] = [x_i, y_i, q_i]represents the coordinates(x_i, y_i)and quality factorq_iof thei^thtower.You are also given an integer array
center = [cx, cy]representing your location, and an integerradius.A tower is reachable if its Manhattan distance from
centeris less than or equal toradius.Among all reachable towers:
- Return the coordinates of the tower with the maximum quality factor.
- If there is a tie, return the tower with the lexicographically smallest coordinate. If no tower is reachable, return
[-1, -1].Manhattan Distance
(x_i, y_i)
(x_j, y_j)
|x_i - x_j| + |y_i - y_j|
A coordinate
[x_i, y_i]is lexicographically smaller than[x_j, y_j]ifx_i < x_j, orx_i == x_jandy_i < y_j.
|x|denotes the absolute value ofx.
1 |
|