C++||Easy to Understand
```\nclass Solution {\npublic:\n    int nearestValidPoint(int x, int y, vector>& p) \n    {\n        int ans=INT_MAX,res=-1;\n        for(int i=0;iabs(x-p[i][0]
```\nclass Solution {\npublic:\n    int nearestValidPoint(int x, int y, vector<vector<int>>& p) \n    {\n        int ans=INT_MAX,res=-1;\n        for(int i=0;i<p.size();i++)\n        {\n            if(x==p[i][0]||y==p[i][1])\n            {\n                if(ans>abs(x-p[i][0])+abs(y-p[i][1]))\n                {\n                    res=i;\n                    ans=abs(x-p[i][0])+abs(y-p[i][1]);\n                }\n            }\n        }\n        return res;\n        \n    }\n};\n//if you like the solution plz upvote.
['C']