def find_min(nums):
    """
    Find minimum element in rotated sorted array

    :param nums: given array
    :type nums: list[int]
    :return: minimum element
    :rtype: int
    """
    left, right = 0, len(nums) - 1
    while left + 1 < right:
        mid = (left + right) // 2
        if nums[mid] < nums[right]:
            right = mid
        elif nums[mid] > nums[right]:
            left = mid
        else:
            # we cannot determine which side is sorted subarray
            # when nums[left] == nums[mid]
            # so just move right pointer step backward
            right -= 1

    if nums[left] < nums[right]:
        return nums[left]
    else:
        return nums[right]