Python Easy Solution
This is simply a Python implementation of the solution at: https://leetcode.com/problems/random-point-in-non-overlapping-rectangles/discuss/154130/Java-randomly
This is simply a Python implementation of the solution at: https://leetcode.com/problems/random-point-in-non-overlapping-rectangles/discuss/154130/Java-randomly-pick-a-rectangle-then-pick-a-point-inside\n\nThe idea is simply to pick a rectangle and pick points in it randomly. \nA dictionary is created to store the sum (total sum) and the corresponding rectangle index. A random sum is chosen and the corresponding key is chosen from the dictionary and random coordinates are generated.\n\n```\nimport random\nclass Solution:\n\n    def __init__(self, rects):\n        """\n        :type rects: List[List[int]]\n        """\n        self.rects = rects\n        self.d = {}\n        self.sum = 0\n        for i in range(len(rects)):\n            self.sum += (rects[i][2] - rects[i][0]+1)*(rects[i][3]-rects[i][1]+1)\n            self.d[self.sum] = i\n            \n    def pick(self):\n        """\n        :rtype: List[int]\n        """\n        area = random.randint(1, self.sum)\n        rect = self.getRect(area)\n        \n        # get a random point from this rectangle\n        coordinates = self.rects[rect]\n        rand_x = random.randint(coordinates[0], coordinates[2])\n        rand_y = random.randint(coordinates[1], coordinates[3])\n        return ([rand_x, rand_y])\n\n    def getRect(self, area):\n        if area in self.d:\n            return self.d[area]\n        \n        mini = []\n        for key in self.d:\n            if key > area:\n                mini.append(key)\n        return self.d[min(mini)]\n# can be simply done as return self.d[min(key for key in self.d if key > area)] \n```
[]