C++ solution using std::discrete_distribution
discrete_distribution can be used to select a random rectangle with weighted probabilities.\n- uniform_int_distribution can be used to select random coordinates
- [discrete_distribution](https://en.cppreference.com/w/cpp/numeric/random/discrete_distribution) can be used to select a random rectangle with weighted probabilities.\n- [uniform_int_distribution](https://en.cppreference.com/w/cpp/numeric/random/uniform_int_distribution) can be used to select random coordinates of a point inside the selected rectangle.\n\n```c++\nclass Solution {\n    vector<vector<int>> rects;\n    mt19937 rng;\n    discrete_distribution<int> dist;\n    \npublic:\n    Solution(vector<vector<int>>& rects_): \n        rects(rects_),\n        rng(random_device()())\n    {\n        vector<int> weights(rects.size());\n        for (int i = 0; i < rects.size(); ++i) {\n            weights[i] = (rects[i][2]-rects[i][0]+1)*(rects[i][3]-rects[i][1]+1);\n        }\n        dist = discrete_distribution<int>(weights.begin(), weights.end());\n    }\n    \n    vector<int> pick() {\n        auto &r = rects[dist(rng)];\n        int x = uniform_int_distribution<int>(r[0], r[2])(rng);\n        int y = uniform_int_distribution<int>(r[1], r[3])(rng);\n        return {x, y};\n    }\n};\n```
[]