public int findMin(int[] nums) {
        if (nums == null) return -1;
        int low = 0, high = nums.length - 1;
        int res = Integer.MAX_VALUE;
        while (low <= high) {
            int mid = low + (high - low) / 2;
            // right half is sorted
            if (nums[low] > nums[mid]) {
                res = Math.min(res, nums[mid]);
                high = mid - 1;
            // left half is sorted
            } else if (nums[low] < nums[mid]) {
                res = Math.min(res, nums[low]);
                low = mid + 1;
            // default to brute force
            } else {
                res = Math.min(res, nums[low]);
                ++low;
            }
        }
        return res;
    }