Skip to content

Commit

Permalink
Q1779 added.
Browse files Browse the repository at this point in the history
  • Loading branch information
isinsuarici committed Mar 8, 2023
1 parent 21d5f67 commit d6d2fca
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions E_1779_FindNearestPointThatHastheSameXorYCoordinate.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class Solution {
public int nearestValidPoint(int x, int y, int[][] points) {
int min=10001;
int index=-1;
for(int i=0;i<points.length;i++){
if(points[i][0]==x || points[i][1]==y){
if(Math.abs(x-points[i][0])+Math.abs(y-points[i][1])<min){
min=Math.abs(x-points[i][0])+Math.abs(y-points[i][1]);
index=i;
}
}
}
return index;
}
}

0 comments on commit d6d2fca

Please sign in to comment.