Simple Solution using binary search and math || C++
Intuition\n Describe your first thoughts on how to solve this problem. \nCount number of points in every rectangle and push till number points in su vector to s
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nCount number of points in every rectangle and push till number points in su vector to search in which rectangle random point will lie .\n# Approach\n<!-- Describe your approach to solving the problem. -->\nBinary Search\n# Complexity\n- Time complexity: O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    int N;\n    long int ar;\n    vector<vector<int>> rec;\n    vector<long int> su;\n    Solution(vector<vector<int>>& rects) {\n        N = rects.size();\n        ar = 0;\n        for(auto x: rects){\n            ar += (x[2]-x[0]+1)*(x[3]-x[1]+1);\n            su.push_back(ar);\n        }\n        rec = rects;\n    }\n    \n    vector<int> pick() {\n        int rval = (rand()%ar);\n        int ithrec = upper_bound(su.begin(), su.end() , rval) - su.begin();\n        long int x = rec[ithrec][2] - rec[ithrec][0] + 1; // number of x points \n        long int y = rec[ithrec][3] - rec[ithrec][1] + 1; // number of y points\n        // Now according to area\n        // rval = su[ithrec] - rval;\n        int fx = rec[ithrec][0] + (rand()%(x));\n        int fy = rec[ithrec][1] + (rand()%(y));\n        return {fx,fy};\n    }\n};\n```
['Math', 'Binary Search', 'C++']