C++ concise solution using binary search (pick with a weight)
First pick a random rectangle with a weight of their areas.\nThen pick a random point inside the rectangle.\n\n\nclass Solution {\npublic:\n    vector<int> v;\n
First pick a random rectangle with a weight of their areas.\nThen pick a random point inside the rectangle.\n\n```\nclass Solution {\npublic:\n    vector<int> v;\n    vector<vector<int>> rects;\n    \n    int area(vector<int>& r) {\n        return (r[2] - r[0] + 1) * (r[3] - r[1] + 1);\n    }\n    \n    Solution(vector<vector<int>> _) {\n        rects = _;\n        for (auto& r : rects) {\n            v.push_back(area(r) + (v.empty() ? 0 : v.back()));\n        }\n    }\n    \n    vector<int> pick() {\n        // https://leetcode.com/problems/random-pick-with-weight/description/\n        int rnd = rand() % v.back();\n        auto it = upper_bound(v.begin(), v.end(), rnd);\n        int idx = it - v.begin();\n        \n        // pick a random point in rect[idx]\n        auto r = rects[idx];\n        return {\n            rand() % (r[2] - r[0] + 1) + r[0],\n            rand() % (r[3] - r[1] + 1) + r[1]\n        };\n    }\n};\n```
[]