With Explanation Comments:  Time: 342 ms (23.70%), Space: 59.4 MB (73.79%)
Like it? ->Upvote please! \u30C4\n\n\'\'\'\nclass Solution {\npublic:\n    int nearestValidPoint(int x, int y, vector>& points) {\n        \n        //initializ
**Like it? ->Upvote please!** \u30C4\n\n\'\'\'\nclass Solution {\npublic:\n    int nearestValidPoint(int x, int y, vector<vector<int>>& points) {\n        \n        //initialize a position & minimum possible absolute value & calculated distance variables\n        int minValue=INT_MAX, dis=0, index=-1;\n        \n        //loop over the whole array elements\n        for(int i=0;i<points.size();i++){\n            \n            //check if the x-coordinates are equals or the y ones\n            if(points[i][0]==x || points[i][1]==y){\n                //calculate the manhattan distance between the two points\n                dis=abs(points[i][0]-x)+abs(points[i][1]-y);            \n                \n                //check if the current distance is smallest reached one\n                if(dis<minValue){\n                    //if no-> save the lowest value\n                    minValue=dis;\n                    //also, the current updated index\n                    index=i;\n                }\n            }\n        }\n        \n        //return the index & if there\'s no one-> return -1 as it initialized before\n        return index;\n    }\n};\n\'\'\'\n\n**Like it? ->Upvote please!** \u30C4\n**If still not understood, feel free to comment. I will help you out**\n**Happy Coding :)**
['Array', 'C', 'C++']