Python3 Easiest and Most understandable solution
The solution has three parts, \n1. Checking the validity of the given points.\n2. Finding the smallest Manhattan distance \n3. returning the index of the smalle
The solution has three parts, \n1. Checking the validity of the given points.\n2. Finding the smallest Manhattan distance \n3. returning the index of the smallest Manhattan distance \n\nWe check if there are no valid points and return -1\n\n# Code\n```\nclass Solution:\n    def nearestValidPoint(self, x: int, y: int, points: List[List[int]]) -> int:\n        valid=[]\n        for i in points:\n            if i[0]==x or i[1]==y:\n                valid.append(i)\n        dist=[]\n        if len(valid) == 0:\n            return -1\n        else :\n            for i in valid:\n                dist.append(abs(x - i[0]) + abs(y - i[1]))\n            if valid[dist.index(min(dist))] in valid:\n                return points.index(valid[dist.index(min(dist))])\n\n\n\n\n          \n\n```
['Python3']