C++ | very easy
\nclass Solution {\npublic:\n    int nearestValidPoint(int x, int y, vector<vector<int>>& points) {\n        int dist=INT_MAX;int ans=-1;\n        for(int i=0;i
```\nclass Solution {\npublic:\n    int nearestValidPoint(int x, int y, vector<vector<int>>& points) {\n        int dist=INT_MAX;int ans=-1;\n        for(int i=0;i<points.size();i++)\n        {\n            if(points[i][0]==x or points[i][1]==y)\n            {\n                int mh=abs(x-points[i][0])+abs(points[i][1]-y);\n                if(mh<dist)\n                {\n                    dist=mh;\n                    ans=i;\n                }\n            }\n          \n        }\n        return ans;\n    }\n};\n```
['C', 'C++']