📌📌 WEIGHTED AREA APPROACH FOR RANDOM INDEX SELECTION📌📌 | Binary Search Solution✅✅
IntuitionApproachComplexity
Time complexity: O(n * log n)

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

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

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

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

# Code
```cpp []
class Solution {
private:
    vector<vector<int>> rects;
    vector<int> areas;
    int totalArea = 0;
public:
    Solution(vector<vector<int>>& rects) {
        this->rects = rects;
        for (auto& rect : rects) {
            int area = (rect[2] - rect[0] + 1) * (rect[3] - rect[1] + 1);
            totalArea += area;
            areas.push_back(totalArea);
        }
        srand(time(0));
    }
    
    vector<int> pick() {
        int randomArea = rand() % totalArea;
        int randomIndex = lower_bound(areas.begin(), areas.end(), randomArea + 1) - areas.begin();
        int xVal = rects[randomIndex][0] + (rand() % (rects[randomIndex][2] - rects[randomIndex][0] + 1));
        int yVal = rects[randomIndex][1] + (rand() % (rects[randomIndex][3] - rects[randomIndex][1] + 1));

        return {xVal, yVal};
    }
};

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