public TreeNode sortedArrayToBST(int[] num) {
        // Start typing your Java solution below
        // DO NOT write main() function

        if (num == null || num.length == 0) {
            return null;
        }

        return toArray(num, 0, num.length - 1);
    }