java Accepted. Clean and Concise. !! Commented !
Please upvote if helpful\n\n\nclass Solution {\n    \n    Random random;\n    TreeMap<Integer,int[]> map;\n    int areaSum = 0;\n    \n    public Solution(int[]
* **Please upvote if helpful**\n\n```\nclass Solution {\n    \n    Random random;\n    TreeMap<Integer,int[]> map;\n    int areaSum = 0;\n    \n    public Solution(int[][] rects) {\n        this.random = new Random();\n        this.map = new TreeMap<>();\n        \n        for(int i = 0; i < rects.length; i++){\n            int [] rectangeCoordinates = rects[i];\n            int length = rectangeCoordinates[2] - rectangeCoordinates[0] + 1 ; // +1 as we need to consider edges also.\n            int breadth = rectangeCoordinates[3] - rectangeCoordinates[1] + 1 ;\n            \n            areaSum += length * breadth;\n            \n            map.put(areaSum,rectangeCoordinates);\n            \n        }\n        \n    }\n    \n    public int[] pick() {\n        int key = map.ceilingKey(random.nextInt(areaSum) + 1); //Don\'t forget to +1 here, because we need [1,area] while nextInt generates [0,area-1]\n        \n        int [] rectangle = map.get(key);\n        \n        int length = rectangle[2] - rectangle[0] + 1 ; // +1 as we need to consider edges also.\n        int breadth = rectangle[3] - rectangle[1] + 1 ;\n        \n        int x = rectangle[0] + random.nextInt(length); //return random length from starting position of x\n        int y = rectangle[1] + random.nextInt(breadth); // return random breadth from starting position of y\n        \n        return new int[]{x,y};\n        \n    }\n}\n\n```
['Java']