------
## 最终结论
```python
def search(nums, target):
    left, right = 0, len(nums) - 1
    
    while left <= right:
        mid = (left + right) // 2
        
        if nums[mid] == target:
            return mid
        
        # Determine which side is sorted
        if nums[left] <= nums[mid]:  # Left side is sorted
            if nums[left] <= target < nums[mid]:  # Target in the left side
                right = mid - 1
            else:  # Target in the right side
                left = mid + 1
        else:  # Right side is sorted
            if nums[mid] < target <= nums[right]:  # Target in the right side
                left = mid + 1
            else:  # Target in the left side
                right = mid - 1
    
    return -1

# Example usage:
# print(search([4,5,6,7,0,1,2], 0))  # Output: 4
# print(search([4,5,6,7,0,1,2], 3))  # Output: -1
```