From f5cf22f760a3ff56eb4cf32a1d0c25bf5c571e5a Mon Sep 17 00:00:00 2001 From: unknown <1326cy@gmail.com> Date: Thu, 27 Aug 2026 22:39:09 +0900 Subject: [PATCH] day29 --- .../4024. Nearest Available Drone.py" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "leetcode3/\353\202\250\355\232\250\354\240\225/4024. Nearest Available Drone.py" diff --git "a/leetcode3/\353\202\250\355\232\250\354\240\225/4024. Nearest Available Drone.py" "b/leetcode3/\353\202\250\355\232\250\354\240\225/4024. Nearest Available Drone.py" new file mode 100644 index 00000000..48be04ca --- /dev/null +++ "b/leetcode3/\353\202\250\355\232\250\354\240\225/4024. Nearest Available Drone.py" @@ -0,0 +1,15 @@ +class Solution: + def nearestDrone(self, drones: list[list[int]], target: list[int]) -> int: + min_dist = float("inf") + ans_idx = -1 + tx, ty = target + + for idx, (x, y, r) in enumerate(drones): + cal_dist = abs(x - tx) + abs(y - ty) + + if cal_dist <= r: + if cal_dist < min_dist: + min_dist = cal_dist + ans_idx = idx + + return ans_idx \ No newline at end of file