[Java]Easy to understand plain segment tree
\nclass Solution {\n    class Node {\n        int low, high;\n        Node left, right;\n        int val;\n        public Node(int low, int high, int val) {\n  
```\nclass Solution {\n    class Node {\n        int low, high;\n        Node left, right;\n        int val;\n        public Node(int low, int high, int val) {\n            this.low = low;\n            this.high = high;\n            this.val = val;\n        }\n        @Override\n        public String toString() {\n            return low + " " + high + " " + val; \n        }\n    } \n    Node root = new Node(0, 1000_000_10, 0);\n    private int query(Node root, int l, int r) { \n        if (l <= root.low && root.high <= r) {\n            return root.val;\n        } \n        int mid = (root.low + root.high) / 2;\n        int res = Integer.MIN_VALUE;\n        if (root.left == null) root.left = new Node(root.low, mid, root.val);\n        if (root.right == null) root.right = new Node(mid + 1, root.high, root.val);\n        if (l <= mid) {\n            res = Math.max(res, query(root.left, l, r));\n        } \n        if (r > mid) {\n            res = Math.max(res, query(root.right, l, r));\n        }\n        return res;\n    }\n    private void update(Node root, int l, int r, int val) { \n        if (l <= root.low && root.high <= r) {\n            root.val = val;\n            root.left = null;\n            root.right = null;\n            return;\n        } \n        int mid = (root.low + root.high) / 2;\n        if (root.left == null) root.left = new Node(root.low, mid, root.val);\n        if (root.right == null) root.right = new Node(mid + 1, root.high, root.val);\n        if (l <= mid) {\n            update(root.left, l, r, val);\n        } \n        if (r > mid) {\n            update(root.right, l, r, val);\n        } \n        root.val = Math.max(root.left.val, root.right.val);\n    }\n    public List<Integer> fallingSquares(int[][] positions) {\n        List<Integer> res = new ArrayList<>();\n        int max = 0;\n        for (int[] p : positions) {\n            int val = query(root, p[0], p[0] + p[1] - 1);\n            update(root, p[0], p[0] + p[1] - 1, p[1] + val);\n            res.add(root.val);\n        }\n        return res;\n    }\n}\n```
[]