Python easy solution O(n)
\ndef nearestValidPoint(self, x, y, p):\n        ind = -1\n        mn = 100000000000000\n        for i in range(len(p)):\n            if x == p[i][0] or y == p[
```\ndef nearestValidPoint(self, x, y, p):\n        ind = -1\n        mn = 100000000000000\n        for i in range(len(p)):\n            if x == p[i][0] or y == p[i][1]:\n                t = abs(x - p[i][0]) + abs(y - p[i][1])\n                if t < mn:\n                    mn, ind = t, i\n        return ind\n```
['Python']