Python Simple Solution Explained (video + code)
https://www.youtube.com/watch?v=mED_K_EaZIo\n\n\nimport random\nclass Solution:\n\n    def __init__(self, rects: List[List[int]]):\n        self.rects = rects\n
https://www.youtube.com/watch?v=mED_K_EaZIo\n[](https://www.youtube.com/watch?v=mED_K_EaZIo)\n```\nimport random\nclass Solution:\n\n    def __init__(self, rects: List[List[int]]):\n        self.rects = rects\n        self.weights = []\n        self.sum_ = 0\n        \n        for x1, y1, x2, y2 in rects:\n            num_points = (x2 - x1 + 1) * (y2 - y1 + 1)\n            self.weights.append(num_points)\n            self.sum_ += num_points\n        \n        self.weights = [x / self.sum_ for x in self.weights]\n\n    def pick(self) -> List[int]:\n        rectangle = random.choices(population = self.rects, weights = self.weights, k=1)[0]\n        x1, y1, x2, y2 = rectangle\n        return [random.randint(x1,x2), random.randint(y1,y2)]\n\n\n# Your Solution object will be instantiated and called as such:\n# obj = Solution(rects)\n# param_1 = obj.pick()\n```
['Python', 'Python3']