✅✅Beats 99% | O(log N) | Python  Solution (using binary search)
Intuition\nThe goal is to find the minimum element in a rotated sorted array. We can use a binary search approach to efficiently locate the minimum element.\n\n
# Intuition\nThe goal is to find the minimum element in a rotated sorted array. We can use a binary search approach to efficiently locate the minimum element.\n\n# Approach\n1. Initialize the `ans` variable with the first element of the array `nums`.\n\n2. Set two pointers, `low` and `high`, to the start and end of the array, respectively.\n\n3. Check if the array is already sorted in ascending order by comparing the elements at the low and high indices. If it is sorted, return the first element, which is the minimum.\n\n4. Perform a binary search by looping while `low` is less than or equal to `high`.\n\n5. Within the loop:\n   - Check if the array is sorted by comparing the elements at the low and high indices. If it is sorted, update `ans` with the minimum of the current `ans` and `nums[low]` and break out of the loop.\n\n   - Calculate the middle index `mid` as the average of `low` and `high`.\n\n   - Update `ans` with the minimum of the current `ans` and `nums[mid]`.\n\n   - Determine if the pivot point (where rotation occurs) is in the right half of the array. If `nums[mid]` is greater than or equal to `nums[low]`, set `low` to `mid + 1`. Otherwise, set `high` to `mid - 1`.\n\n6. Return the final value of `ans`, which is the minimum element in the rotated sorted array.\n\n# Complexity\n- Time complexity: The binary search approach has a time complexity of O(log N), where N is the size of the input array `nums`.\n- Space complexity: The space complexity is O(1) as we only use a few variables for tracking and no additional data structures.\n\n\n# Code\n```\nclass Solution:\n    def findMin(self, nums: List[int]) -> int:\n        ans = nums[0]\n        low, high = 0, len(nums) - 1\n\n        if nums[low] < nums[high]:\n            return nums[low]\n\n        while low <= high:\n            if nums[low] < nums[high]:\n                ans = min(ans, nums[low])\n                break\n            \n            mid = (low + high) // 2\n            ans = min(ans, nums[mid])\n\n            \n            if nums[mid] >= nums[low]:\n                low = mid + 1\n            else:\n                high = mid - 1\n\n        return ans\n\n```\n\n# Please upvote the solution if you understood it.\n![1_3vhNKl1AW3wdbkTshO9ryQ.jpg](https://assets.leetcode.com/users/images/47213b8f-a629-4b55-b2c7-0710a070dd63_1697382195.318308.jpeg)\n
['Binary Search', 'Python3']