Find Nearest Point That Has the Same X or Y Coordinate Solution in C++
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nO(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nO(1)\n# Code\n```\nclass Solution {\npublic:\n    int nearestValidPoint(int x, int y, vector<vector<int>>& points) {\n        int i, ind=-1, distance, min_dis=100000;\n        for(i=0 ; i<points.size() ; i++)\n        {\n            if(points[i][0]==x || points[i][1]==y)\n            {\n                distance = abs(points[i][0]-x) + abs(points[i][1]-y);\n                if(distance<min_dis)\n                {\n                    min_dis = distance;\n                    ind = i;\n                }\n            }\n        }\n        return ind;\n    }\n};\n```
['C++']