The Easiest Java Segmentation Tree with Lazy Propagation.
\nclass Solution {\n    class SegmentTree {\n        Node root;\n        public SegmentTree (int low, int high) {\n            root = new Node(low, high);\n    
```\nclass Solution {\n    class SegmentTree {\n        Node root;\n        public SegmentTree (int low, int high) {\n            root = new Node(low, high);\n        }\n        public void update (int L, int R, Node node, int val) {\n            if (L <= node.low && R >= node.high) {\n                node.lazy = Math.max(node.lazy, val);\n            } \n            push(node);\n            if ((L <= node.low && R >= node.high) || L > node.high || R < node.low) {\n                return;\n            } \n            update(L, R, node.left, val);\n            update(L, R, node.right, val);\n            node.max = Math.max(node.left.max, node.right.max);\n        } \n        public int query (int L, int R, Node node) {\n            push(node);\n            if (L > node.high || R < node.low) return 0;\n            if (L <= node.low && R >= node.high) return node.max;\n            return Math.max(query(L, R, node.left), query(L, R, node.right));\n        } \n        public void push (Node node) {\n            node.max = Math.max(node.max, node.lazy);\n            if (node.low != node.high) {\n                int mid = (node.low + node.high) / 2;\n                if (node.left == null) {\n                    node.left = new Node(node.low, mid);\n                }  \n                if (node.right == null) {\n                    node.right = new Node(mid + 1, node.high);\n                } \n                node.left.lazy = Math.max(node.left.lazy, node.lazy);\n                node.right.lazy = Math.max(node.right.lazy, node.lazy);\n            }\n            node.lazy = 0;\n        } \n    }\n    class Node {\n        int low, high;\n        int max, lazy;\n        Node left, right;\n        public Node (int low, int high) {\n            this.low = low;\n            this.high = high;\n        }\n    }\n    public List<Integer> fallingSquares(int[][] positions) {\n        List<Integer> res = new ArrayList<>();\n        SegmentTree st = new SegmentTree(0, 110_000_000);\n        int max = 0;\n        for (int[] p : positions) {\n            int s = p[0], e = p[0] + p[1] - 1;\n            int tmp = st.query(s, e, st.root);\n            st.update(s, e, st.root, tmp + p[1]);\n            max = Math.max(max, st.root.max);\n            res.add(max);\n        }\n        return res;\n    }\n} \n```
[]