public static int findMin(int[] nums) {
        if (nums == null || nums.length == 0)
            return 0;
        int begin = 0, end = nums.length - 1;
        while (begin + 1 < end) {
            int mid = begin + (end - begin) / 2;
            int val = nums[mid];
            if (val < nums[end]) {
                // right part is sorted
                end = mid;
            } else if (val > nums[end]) {
                begin = mid;
            } else
                --end;
        }
        if (nums[begin] < nums[end])
            return nums[begin];
        return nums[end];
    }