2 parents c512554 + 6082f49 commit 08fb64fCopy full SHA for 08fb64f
1 file changed
leetcode3/이진희/4024. Nearest Available Drone.java
@@ -0,0 +1,28 @@
1
+/*
2
+
3
+1. 아이디어 : 가장 가까운 범위를 만족하는 드론 찾기
4
5
+2. 시간복잡도 : O(100)
6
7
+3. 자료구조/알고리즘 : 계산
8
9
+ */
10
11
+class Solution {
12
+ public int nearestDrone(int[][] drones, int[] target) {
13
+ // 더 가까운 드론 찾기
14
15
+ int idx = -1;
16
+ int minDis = 10000000;
17
18
+ for(int i=0; i<drones.length; i++) {
19
+ int len = Math.abs(drones[i][0] - target[0]) + Math.abs(drones[i][1] - target[1]);
20
+ if(drones[i][2]<len || minDis<=len) continue;
21
22
+ minDis = len;
23
+ idx = i;
24
+ }
25
26
+ return idx;
27
28
+}
0 commit comments