public TreeNode sortedArrayToBST(int[] num) {
        if(num == null || num.length == 0) return null;
        TreeNode root = new TreeNode(num[num.length / 2]);
        if(0 < num.length/2)
            visit(root, 0, num.length/2-1, num, true);
        if(num.length/2+1 < num.length)
            visit(root, num.length/2+1, num.length-1, num, false);
        return root;
    }