Python clean solution
\nclass Solution:\n    def nearestValidPoint(self, x: int, y: int, points: List[List[int]]) -> int:\n        def compute_dist(x1, y1, x2, y2):\n            retu
```\nclass Solution:\n    def nearestValidPoint(self, x: int, y: int, points: List[List[int]]) -> int:\n        def compute_dist(x1, y1, x2, y2):\n            return abs(x1-x2) + abs(y1-y2)\n        \n        min_idx, min_dist = -1, float(\'inf\')\n        \n        for i, (x_hat, y_hat) in enumerate(points):\n            if x_hat == x or y_hat == y:\n                curr_dist = compute_dist(x, y, x_hat, y_hat)\n                if curr_dist < min_dist:\n                    min_idx = i\n                    min_dist = curr_dist\n        return min_idx\n```
[]