import java.util.*; /* * public class TreeNode { * int val = 0; * TreeNode left = null; * TreeNode right = null; * } */ public class Solution { /** * * @param num int整型一维数组 * @return TreeNode类 */ public TreeNode sortedArrayToBST (int[] num) { return help(num , 0 , num.length - 1) ; } public TreeNode help(int[] num , int start , int end) { if(start > end) return null ; int mid = start + (end - start) / 2 ; TreeNode node = new TreeNode(num[mid]) ; node.left = help(num , start , mid - 1) ; node.right = help(num , mid + 1 , end) ; return node ; } }