Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
public class Solution { public TreeNode sortedArrayToBST(int[] num) { return sortedArrayToBST(num, 0, num.length-1); } public TreeNode sortedArrayToBST(int[] num, int start, int end){ if(start>end){ return null; } int pivot = (start+end)/2; TreeNode root = new TreeNode(num[pivot]); root.left = sortedArrayToBST(num, start, pivot-1); root.right = sortedArrayToBST(num, pivot+1, end); return root; } }