[Java] Distribute The Points via TreeMap
\nclass Solution {\n    private TreeMap<Integer, Integer> map;\n    private int[][] minmax;\n    private int len;\n    private int sum;\n    \n    public Soluti
```\nclass Solution {\n    private TreeMap<Integer, Integer> map;\n    private int[][] minmax;\n    private int len;\n    private int sum;\n    \n    public Solution(int[][] rects) {\n        map = new TreeMap<>();\n        len = rects.length;\n        minmax = new int[len][4];\n        sum = 0;\n        for (int i = 0; i < len; i++) {\n            minmax[i][0] = Math.min(rects[i][0], rects[i][2]);\n            minmax[i][1] = Math.max(rects[i][0], rects[i][2]);\n            minmax[i][2] = Math.min(rects[i][1], rects[i][3]);\n            minmax[i][3] = Math.max(rects[i][1], rects[i][3]);\n            sum += (rects[i][3] - rects[i][1] + 1) * (rects[i][2] - rects[i][0] + 1);\n            map.put(sum, i);\n        }\n    }\n    \n    public int[] pick() {\n        int rand = 1 + (int)(Math.random() * sum);\n        int index = map.get(map.ceilingKey(rand));\n        int[] rect = minmax[index];\n        int xrange = rect[1] - rect[0] + 1;\n        int yrange = rect[3] - rect[2] + 1;\n        return new int[]{rect[0] + (int)(Math.random() * xrange), rect[2] + (int)(Math.random() * yrange)};\n    }\n}\n```
[]