@@ -0,0 +1,1627 @@
+package leetcode.construct_binary_tree_from_preorder_and_inorder_traversal;%0A%0Aimport common.TreeNode;%0A%0Apublic class Solution %7B%0A%09public TreeNode buildTree(int%5B%5D preorder, int%5B%5D inorder, int pre_from, int pre_to, int in_from, int in_to)%7B%0A%09%09if(in_from == in_to %7C%7C pre_from == pre_to) return null;%0A%09%09int rootval = preorder%5Bpre_from%5D;%0A%09%09TreeNode root = new TreeNode(rootval);%0A%09%09int rootidx;%0A%09%09for(rootidx = in_from; rootidx %3C in_to && inorder%5Brootidx%5D != rootval; rootidx++);%0A%09%09System.err.println(rootidx);%0A%09%09root.left = buildTree(preorder, inorder, pre_from + 1, pre_from + 1 + (rootidx - in_from), in_from, rootidx);%0A%09%09root.right = buildTree(preorder, inorder, pre_to + 1 - (in_to - rootidx), pre_to, rootidx + 1, in_to);%0A%09%09return root;%0A%09%7D%0A%09public TreeNode buildTree(int%5B%5D preorder, int%5B%5D inorder) %7B%0A%09%09if(inorder == null %7C%7C preorder == null) return null;%0A    %09return buildTree(preorder, inorder, 0, inorder.length, 0, preorder.length);%0A    %7D%0A    %0A    public static void inOrder(TreeNode cur)%7B%0A    %09if(cur != null)%7B%0A    %09%09inOrder(cur.left);%0A    %09%09System.err.print(cur.val + %22-%3E%22);%0A    %09%09inOrder(cur.right);%0A    %09%7D%0A    %7D%0A    %0A    public static void preOrder(TreeNode cur)%7B%0A    %09if(cur != null)%7B%0A    %09%09System.err.print(cur.val + %22-%3E%22);%0A    %09%09preOrder(cur.left);%0A    %09%09preOrder(cur.right);%0A    %09%7D%0A    %7D%0A    %0A    public static void main(String%5B%5D args)%7B%0A    %09int%5B%5D preorder = new int%5B%5D%7B1, 5, 4, 9, 3, 8, 6, 7%7D;%0A    %09int%5B%5D inorder = new int%5B%5D%7B4, 9, 5, 1, 8, 3, 7, 6%7D;%0A    %09TreeNode ret = new Solution().buildTree(preorder, inorder);%0A    %09preOrder(ret);%0A    %09System.err.println(%22%22);%0A    %09inOrder(ret);%0A    %09System.err.println(%22%22);%0A    %7D%0A%7D%0A

Add java solution for 105. Construct Binary Tree from Preorder and Inorder Traversal