Easy to understand - Python 3
class Solution:\n    def nearestValidPoint(self, x: int, y: int, points: List[List[int]]) -> int:\n        \n        min_d=1000000\n        i=0\n        ans=-1\
class Solution:\n    def nearestValidPoint(self, x: int, y: int, points: List[List[int]]) -> int:\n        \n        min_d=1000000\n        i=0\n        ans=-1\n        for point in points:\n            if x==point[0] or y == point[1]:\n                mah = abs(x-point[0]) + abs(y-point[1])\n                if mah<min_d:\n                    min_d=mah\n                    ans=i\n            i+=1\n        return ans\n            \n
[]