[Java] 100% Solution
~~~java\n\nclass Solution {\n    // 1. pick a rect\n    // 2. pick a point inside this rect\n    int[][] rects;\n    int[] prefixWeights;\n    Random rd;\n\n   
~~~java\n\nclass Solution {\n    // 1. pick a rect\n    // 2. pick a point inside this rect\n    int[][] rects;\n    int[] prefixWeights;\n    Random rd;\n\n    public Solution(int[][] rects) {\n        this.rects = rects;\n        this.prefixWeights = new int[rects.length];\n        this.rd = new Random();\n        \n        for (int i = 0; i < rects.length; i++) {\n            int[] rect = rects[i];\n            int width = rect[2] - rect[0] + 1;\n            int height = rect[3] - rect[1] + 1;\n            prefixWeights[i] = (i == 0 ? 0 : prefixWeights[i - 1]) + width * height;\n        }\n    }\n    \n    public int[] pick() {\n        int rdWeight = rd.nextInt(prefixWeights[prefixWeights.length - 1]);\n        int rectIdx = findFirstGreater(rdWeight);\n        int[] rect = rects[rectIdx];\n        \n        int width = rect[2] - rect[0] + 1;\n        int height = rect[3] - rect[1] + 1;\n        int total = width * height;\n        int rdPoint = rd.nextInt(total);\n        return new int[]{\n            rect[0] + rdPoint % width,\n            rect[1] + rdPoint / width\n        };\n    }\n    \n    private int findFirstGreater(int target) {\n        int l = 0, r = prefixWeights.length - 1;\n        while (l < r - 1) {\n            int mid = l + (r - l) / 2;\n            if (prefixWeights[mid] <= target) {\n                l = mid + 1;\n            } else {\n                r = mid;\n            }\n        }\n        return prefixWeights[l] > target ? l : r;\n    }\n}\n\n\n~~~
[]