```
public class Solution {
public TreeNode sortedArrayToBST(int[] num) {
if(num == null){
return null;
}
if(num.length == 1){
return new TreeNode(num[0]);
}
int mid = (num.length-1) /2;
TreeNode root = new TreeNode(num[mid]);
root.left = breakArray(0, mid-1, num, root);
root.right = breakArray(mid+1,num.length-1,num,root);
return root;
}
public TreeNode breakArray(int start, int end, int[] num, TreeNode root){
if(start == end){
return new TreeNode(num[start]);
}
if(start > end){
return null;
}
int mid = (end-start)/2;
TreeNode n_root = new TreeNode(num[mid]);
root.left = breakArray(start, mid-1, num, n_root);
root.right = breakArray(mid+1,end,num,n_root);
return n_root;
}
}
```

I tried several tests in IDEONE, an online compiler and it runs smoothly. I don't know why it just went wrong here. Thank you!