标签:turn search return new null class int [] nbsp
1 class Solution { 2 public TreeNode sortedArrayToBST(int[] nums) { 3 int size = nums.length; 4 return helper(nums, 0, size - 1); 5 6 } 7 8 public TreeNode helper(int[] nums, int lo, int hi) { 9 if(lo > hi) return null; 10 int mid = lo + (hi - lo) / 2; 11 TreeNode root = new TreeNode(nums[mid]); 12 root.left = helper(nums, lo , mid-1); 13 root.right = helper(nums, mid+1, hi); 14 return root; 15 } 16 }
108. Convert Sorted Array to Binary Search Tree
标签:turn search return new null class int [] nbsp
原文地址:https://www.cnblogs.com/goPanama/p/9678665.html