Java || faster than 100% || Simple solution
\nclass Solution {\n    public int nearestValidPoint(int x, int y, int[][] points) {\n        int min = Integer.MAX_VALUE;\n        int index = -1;\n        for
```\nclass Solution {\n    public int nearestValidPoint(int x, int y, int[][] points) {\n        int min = Integer.MAX_VALUE;\n        int index = -1;\n        for (int i = 0; i < points.length; i++) {\n            int[] point = points[i];\n            if (point[0] == x) {\n                int d = Math.abs(y - point[1]);\n                if (d < min) {\n                    index = i;\n                    min = d;\n                }\n            } else if (point[1] == y) {\n                int d = Math.abs(x - point[0]);\n                if (d < min) {\n                    index = i;\n                    min = d;\n                }\n            }\n        }\n        return index;\n    }\n}\n```
['Java']