Easiest and Fastest Solution
Please Upvote (^_^)\n\nclass Solution {\n    public int nearestValidPoint(int x, int y, int[][] point) {\n        int ans=Integer.MAX_VALUE;\n        int var=-1
Please Upvote (^_^)\n```\nclass Solution {\n    public int nearestValidPoint(int x, int y, int[][] point) {\n        int ans=Integer.MAX_VALUE;\n        int var=-1;\n        for(int i=0;i<point.length;i++)\n        {\n            \n            if(point[i][0]==x || point[i][1]==y)\n            {\n                int m=Math.abs(x-point[i][0])+Math.abs(y-point[i][1]);\n                if(m<ans)\n                {\n                    ans=m;\n                    var=i;\n                }\n            }\n        }\n        return var;\n    }\n}\n```
[]