Python readable, commented solution, without using bisect
The idea is simple;\n\n1. Choose a rect, then choose a point inside it.\n2. The bigger the rectangle, the higher the probability of it getting chosen\n\n\nimpor
The idea is simple;\n\n1. Choose a rect, then choose a point inside it.\n2. The bigger the rectangle, the higher the probability of it getting chosen\n\n```\nimport random\n\nclass Solution:\n\n    def __init__(self, rects: List[List[int]]):\n        self.rects = rects\n\n        \n        # I am more of a list comprehensions guy, but if you prefer to\n        # put more effort with the keyboard, here\'s an unrolled version.\n        \n        # self.weights = []\n        # for rect in rects:\n        #     x1, y1, x2, y2 = rect\n        #     area = (x2-x1+1)*(y2-y1+1)\n        #     self.weights.append(area)\n        \n        self.weights = [(x2-x1+1)*(y2-y1+1) for x1, y1, x2, y2 in rects]\n        \n            \n        # library functions are always faster\n        # it beats the runtime of using an extra variable \n        # to calculate sum_of_weights in the loop above\n        # even if that means, we have to iterate once more.\n        # Such is the world of python :D\n        sum_of_weights = sum(self.weights)\n        \n        self.weights = [x/sum_of_weights for x in self.weights]\n            \n\n    def pick(self) -> List[int]:\n        rect = random.choices(\n            population=self.rects,\n            weights=self.weights,\n            k=1\n        )[0]  # random.choices returns a list, we extract the first (and only) element.\n\n        x1, y1, x2, y2 = rect  # tuple unpacking\n        \n        rnd_x = random.randint(x1, x2)\n        rnd_y = random.randint(y1, y2)\n        return [rnd_x, rnd_y]\n        \n\n\n# Your Solution object will be instantiated and called as such:\n# obj = Solution(rects)\n# param_1 = obj.pick()\n```\n
['Python']