[python] - easy to understand
Iterating through the all points with enumerate(points) that returns index (i)  and value (point)\nIf the current candidate (point) don\'t have either same X ax
Iterating through the all points with `enumerate(points)` that returns index (i)  and value (point)\nIf the current candidate (point) don\'t have either same X axis or Y axis - skip it and go to the next one. Continue inside the loop only if current point is "valid".\nCalculate smallest distance (dist) by comparing to the maximum possible (20,000 due to constraints of the task)\nAs soon as we see better then current best - update the best (dist) and remember its index (i).\nIf we see as good as but **not** better abs(point[0] - x) + abs(point[1] - y) **<** dist - ignore\n\nReturn index of first best\n```\nclass Solution:\n    def nearestValidPoint(self, x: int, y: int, points: List[List[int]]) -> int:\n        dist = 20_000\n        ans = -1\n        for i, point in enumerate(points):\n            if point[0] == x or point[1] == y:\n                if abs(point[0] - x) + abs(point[1] - y) < dist:\n                    dist = abs(point[0] - x) + abs(point[1] - y)\n                    ans = i\n        return ans\n```
[]