JAVA_LeetCode 1779_Find Nearest Point That Has the Same X or Y Coordinate 풀이 class Solution { public int nearestValidPoint(int x, int y, int[][] points) { // x와 y중 하나라도 일치하는 경우 거리차이가 가장 작은 최소값을 구한다. // 없는 경우 -1을 반환한다. int min = Integer.MAX_VALUE, idx = -1, x2 = 0, y2 = 0, diff = 0; for(int i = 0; i < points.length; i++){ int[] point = points[i]; x2 = point[0]; y2 = point[1]; if(x == x2 || y == y2){ // 최소값중 가장 작은 인덱스를 찾는다. diff = Math.abs(x - x2) + Math.abs(y - y2); if(diff < min){ min = diff; id...
#
JAVA
#
JAVA_FindNearestPointThatHastheSameXorYCoordinate
#
JAVA_LeetCode1779
#
JAVA_LeetCode1779_FindNearestPointThatHastheSameXorYCoordinate
#
LeetCode1779_FindNearestPointThatHastheSameXorYCoordinate