C++ 100% beat
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
    vector<vector<int>>& rects;
    int total_area;
    vector<int>  range_by_rect;
    mt19937 rng;
public:
    Solution(vector<vector<int>>& rects) : rng(random_device{}()),rects(rects){
        range_by_rect.resize(size(rects));
        range_by_rect[0] = 0;
        total_area = 0;
        for(int i=0;i<size(rects);i++){
            int curr_area = (rects[i][3] - rects[i][1] +1)*(rects[i][2] - rects[i][0]+1);
            total_area += curr_area;
            if (i < size(rects)-1)
                range_by_rect[i+1] = range_by_rect[i] + curr_area;
        }
    }
    int get_rand(int n){
        uniform_int_distribution<int> dist(0, n-1);
        return dist(rng);
    }
    vector<int> pick() {
        int rand_rect_indx = (upper_bound(range_by_rect.begin(),range_by_rect.end(),get_rand(total_area))-1)
                              -range_by_rect.begin();
        auto& random_rect = rects[rand_rect_indx];
        int w= random_rect[2] - random_rect[0] +1;
        int h= random_rect[3] - random_rect[1] + 1;
        int x = random_rect[0] + get_rand(w);
        int y = random_rect[1] + get_rand(h);
        return {x,y};


    }
};

/**
 * Your Solution object will be instantiated and called as such:
 * Solution* obj = new Solution(rects);
 * vector<int> param_1 = obj->pick();
 */
```
['C++']