Java. Arrays. Find Nearest Point That Has the Same X or Y Coordinate
\n\nclass Solution {\n    public int nearestValidPoint(int x, int y, int[][] points) {\n        int minManh = Integer.MAX_VALUE;\n        int indMin = -1;\n    
\n```\nclass Solution {\n    public int nearestValidPoint(int x, int y, int[][] points) {\n        int minManh = Integer.MAX_VALUE;\n        int indMin = -1;\n        for (int i = 0; i < points.length; i++)\n        {\n            int tmpManh = Math.abs(x - points[i][0]) + Math.abs(y - points[i][1]);\n            if ((x == points[i][0] || y == points[i][1]) && (tmpManh < minManh))\n            {\n                minManh = tmpManh;\n                indMin = i;\n            }\n        }\n        return indMin;\n    }\n}\n```
['Array', 'Java']