diff --git "a/leetcode3/\353\263\200\354\247\200\355\230\221/v2/4024. Nearest Available Drone.py" "b/leetcode3/\353\263\200\354\247\200\355\230\221/v2/4024. Nearest Available Drone.py" new file mode 100644 index 00000000..2bd7cf66 --- /dev/null +++ "b/leetcode3/\353\263\200\354\247\200\355\230\221/v2/4024. Nearest Available Drone.py" @@ -0,0 +1,18 @@ +class Solution: + def nearestDrone(self, drones: list[list[int]], target: list[int]) -> int: + lst = [] + tx,ty = target + + for x,y,r in drones: + distance = abs(x-tx) + abs(y-ty) + if distance <= r: + lst.append(distance) + else: + lst.append(99999) + + _min = min(lst) + + if _min == 99999: + return -1 + else: + return lst.index(_min) \ No newline at end of file