[Java] Standard TreeMap solution           [Detailed]
Save Pair(left, right) as key and height as value into TreeMap.\n\nPair start = map.lowerKey(p1);\nPair end = map.lowerKey(p2);\n\n1. Modify the end interval if
Save `Pair(left, right)` as key and `height` as value into TreeMap.\n```\nPair start = map.lowerKey(p1);\nPair end = map.lowerKey(p2);\n```\n1. Modify the `end` interval if it intersects with `[left, right]`\n2. Modify the `start` interval if it intersects with `[left, right]`\n3. Seach in `subMap = map.subMap(p1, true, p2, false)` to find max height\n4. clear all intervals in range `[left, right]`\n5. put new range into map\n```\nclass Solution {\n    class Pair {\n        int left;\n        int right;\n        public Pair(int l, int r) {\n            left = l;\n            right = r;\n        }\n        public String toString() {\n            return left +","+right;\n        }\n    }\n    public List<Integer> fallingSquares(int[][] positions) {\n        List<Integer> res = new ArrayList<>();\n        TreeMap<Pair, Integer> map = new TreeMap<>((a, b) -> a.left - b.left);\n        int max = 0;\n        \n        for (int[] square : positions) {\n            int left = square[0];\n            int right = square[0] + square[1];\n            int height = square[1];\n            Pair p1 = new Pair(left, 0);\n            Pair p2 = new Pair(right, 0);\n            \n            int maxH = 0;\n            Pair start = map.lowerKey(p1);\n            Pair end = map.lowerKey(p2);\n            \n            if (end != null && end.right > right) { // change end before start\n                int h = map.get(end);\n                int r = end.right;\n                maxH = Math.max(maxH, h);       // compare with intersact range\n                map.put(new Pair(right, r), h);\n            }\n            if (start != null && start.right > left) {\n                int h = map.get(start);   \n                int l = start.left;\n                maxH = Math.max(maxH, h);  \n                map.put(new Pair(l, left), h);\n            }\n            \n            Map<Pair, Integer> submap = map.subMap(p1, true, p2, false);\n            for (Pair key : submap.keySet()) {\n                maxH = Math.max(maxH, map.get(key));\n            }\n            submap.clear();                     // remove intervals in range\n            \n            int newH = height + maxH;\n            map.put(new Pair(left, right), newH);    // put new range\n            \n            max = Math.max(max, newH);\n            res.add(max);\n        } \n        return res;\n    }\n}\n```
[]