Python Binary Search
\nclass Solution:\n    def __init__(self, rects: List[List[int]]):\n        self.rects = rects\n        self.search_space = []\n\n        for i, rect in enumera
```\nclass Solution:\n    def __init__(self, rects: List[List[int]]):\n        self.rects = rects\n        self.search_space = []\n\n        for i, rect in enumerate(rects):\n            a, b, c, d = rect\n            self.search_space.append((d - b + 1) * (c - a + 1))\n            if i != 0:\n                self.search_space[i] += self.search_space[i - 1]\n      \n\n    def pick(self) -> List[int]:\n        randval = random.randint(0, self.search_space[-1] - 1)\n\n        low = 0\n        high = len(self.search_space) - 1\n\n        while low < high:\n            midpt = low + (high - low) // 2\n\n            if self.search_space[midpt] <= randval:\n                low = midpt + 1\n            else:\n                high = midpt\n\n\n        rect = self.rects[low]\n        rect_range = randval\n\n        if low > 0:\n            rect_range -= self.search_space[low - 1] \n\n\n        a, b, c, d = rect\n\n        return [(rect_range % (c - a + 1)) + a, (rect_range // (c - a + 1)) + b]\n```
['Binary Tree', 'Python', 'Python3']