@@ -0,0 +1,982 @@
+package leetcode;%0A%0A/**%0A * https://leetcode.com/problems/construct-binary-search-tree-from-preorder-traversal/%0A */%0Apublic class Problem1008 %7B%0A    public static class TreeNode %7B%0A        int val;%0A        TreeNode left;%0A        TreeNode right;%0A%0A        TreeNode(int x) %7B%0A            val = x;%0A        %7D%0A    %7D%0A%0A    public TreeNode bstFromPreorder(int%5B%5D preorder) %7B%0A        return bstFromPreorder(preorder, new IntRef(), Integer.MAX_VALUE);%0A    %7D%0A%0A    private static TreeNode bstFromPreorder(int%5B%5D preOrder, IntRef index, int max) %7B%0A        if (index.val == preOrder.length) %7B%0A            return null;%0A        %7D%0A        int val = preOrder%5Bindex.val%5D;%0A        if (val %3E max) %7B%0A            return null;%0A        %7D%0A        index.val++;%0A        TreeNode node = new TreeNode(val);%0A        node.left = bstFromPreorder(preOrder, index, val);%0A        node.right = bstFromPreorder(preOrder, index, max);%0A        return node;%0A    %7D%0A%0A    private static class IntRef %7B%0A        private int val;%0A    %7D%0A%7D%0A

Solve problem 1008