JAVA 10+ lines TreeMap Sorted With Area
I borrow the idea from 880. Random Pick with Weight\nBut this time we use area as key.\n\nclass Solution {\n    TreeMap<Integer, int[]> map= new TreeMap<>();\n 
I borrow the idea from [880. Random Pick with Weight\n](https://leetcode.com/problems/random-pick-with-weight/discuss/154024/JAVA-8-lines-TreeMap)But this time we use area as key.\n```\nclass Solution {\n    TreeMap<Integer, int[]> map= new TreeMap<>();\n    Random rnd= new Random();\n    int area= 0;\n    public Solution(int[][] rects) {\n        for (int[] r: rects){\n            int x1=r[0], y1=r[1], x2=r[2], y2=r[3];\n            area+=(x2-x1+1)*(y2-y1+1); \\\\Don\'t forget to +1 here, because e.g 1~5 has 5 valid numbers\n            map.put(area, r);\n        }\n    }\n    \n    public int[] pick() {\n        int key= map.ceilingKey(rnd.nextInt(area)+1); \\\\Don\'t forget to +1 here, because we need [1,area] while nextInt generates [0,area-1]\n        int[] curRec= map.get(key);\n        int x1=curRec[0], y1=curRec[1], x2=curRec[2], y2=curRec[3], length=x2-x1, width=y2-y1;\n        int x=x1+rnd.nextInt(length+1), y=y1+rnd.nextInt(width+1);\n        return new int[]{x, y};\n    }\n}\n```\nHappy Coding!
[]