Skip to content

Commit 91fd017

Browse files
committed
4024
1 parent cf02da1 commit 91fd017

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution:
2+
def nearestDrone(self, drones: list[list[int]], target: list[int]) -> int:
3+
lst = []
4+
tx,ty = target
5+
6+
for x,y,r in drones:
7+
distance = abs(x-tx) + abs(y-ty)
8+
if distance <= r:
9+
lst.append(distance)
10+
else:
11+
lst.append(99999)
12+
13+
_min = min(lst)
14+
15+
if _min == 99999:
16+
return -1
17+
else:
18+
return lst.index(_min)

0 commit comments

Comments
 (0)