Simple Java Solution
\n\n# Code\n\nclass Solution {\n    public int nearestValidPoint(int x, int y, int[][] points) {\n\n        int min = Integer.MAX_VALUE,index=-1;\n        for(i
\n\n# Code\n```\nclass Solution {\n    public int nearestValidPoint(int x, int y, int[][] points) {\n\n        int min = Integer.MAX_VALUE,index=-1;\n        for(int i=0;i<points.length;i++){\n            int dist = Math.abs(points[i][0]-x) + Math.abs(points[i][1]-y);\n            if((points[i][0] == x || points[i][1] == y) && min > dist){\n                // if(min > dist){\n                    min = dist;\n                    index=i;\n                // }\n            }\n        } \n        return index;       \n    }\n}\n```
['Java']