JAVA SOLUTION 2ms runtime 🎃
Java Solution for \'Find Nearest Point That has the same X or Y Coordinate.\nRuntime - 2ms\nBeats - 95%\n\nclass Solution {\n    public int nearestValidPoint(in
Java Solution for \'Find Nearest Point That has the same X or Y Coordinate.\nRuntime - 2ms\nBeats - 95%\n```\nclass Solution {\n    public int nearestValidPoint(int x, int y, int[][] points) {\n        int result = -1, minSum = Integer.MAX_VALUE;\n        for (int i = 0; i < points.length; i++) {\n            if (points[i][0] == x) {\n                int manh = Math.abs(y - points[i][1]);\n                if (minSum > manh) {\n                    minSum = manh;\n                    result = i;\n                }\n            } else if (points[i][1] == y) {\n                int manh = Math.abs(x - points[i][0]);\n                if (minSum > manh) {\n                    minSum = manh;\n                    result = i;\n                }\n            }\n        }\n        return result;\n    }\n}\n```
['Java']