@@ -0,0 +1,1037 @@
+package com.fulin.Tree;%0A%0Aimport com.fulin.Utils.TreeNode;%0A%0A/**%0A * Created by fulin on 18-1-31.%0A */%0Apublic class ConvertSortedArraytoBST %7B%0A    public static void main(String%5B%5D args)%7B%0A        int%5B%5D nums = %7B-10,-3,0,5,9%7D;%0A        TreeNode result = sortedArrayToBST(nums);%0A        System.out.println(result.val);%0A    %7D%0A%0A    public static TreeNode sortedArrayToBST(int%5B%5D nums) %7B%0A        if(nums == null)%7B%0A            return null;%0A        %7D%0A%0A        if(nums.length == 1)%7B%0A            return new TreeNode(nums%5B0%5D);%0A        %7D%0A%0A        return helper(nums,0,nums.length - 1);%0A    %7D%0A%0A    public static TreeNode helper(int%5B%5D nums , int start , int end)%7B%0A%0A        if(start%3C0 %7C%7C end %3E= nums.length %7C%7C start %3E end)%7B%0A            return  null;%0A        %7D%0A%0A        if(start == end)%7B%0A            return new TreeNode(nums%5Bstart%5D);%0A        %7D%0A%0A        int index = (start + end) / 2;%0A        TreeNode tree = new TreeNode(nums%5Bindex%5D);%0A        tree.left = helper(nums,start,index - 1);%0A        tree.right = helper(nums,index+1,end);%0A        return tree;%0A    %7D%0A%7D%0A

leetcode :108. Convert Sorted Array to Binary Search Tree