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