✅PYTHON || Explained Steps || Clean Code 🔥||✔️ Best Method
Hello!\n\nTo solve this problem we have to do binary search, but we compare current element with the second one and then with the last one.\n\n1. If our current
Hello!\n\nTo solve this problem we have to do **binary search**, but we compare current element with the **second one** and then with the **last one**.\n\n1. If our current element is greater than the next one, then it means that next element is our **result** (because it means it is rotation point)\n2. If our current element is greater than the last element, then it means that we have to move **start** index (because on the left we won\'t find the target).\n3. If those statements are not true, then we change **end** index.\n\nFor example: [4, 5, 1, 2, 3],  target = 5\nOur mid point is value **1**. It is not greater than **2**, so it is not the target. It is not greater than the last value, so we know, that we won\'t find the target on the right, so we decrease **end** index.\n\nNow we consider subarray [4, 5] etc.\n\nCode:\n```\nclass Solution:\n    def findMin(self, nums: List[int]) -> int:\n        if len(nums) == 1:\n            return nums[0]\n        \n        start = 0\n        end = len(nums)-1\n        \n        while start <= end:\n            mid = (start + end) // 2\n            \n            if nums[mid] > nums[mid+1]:\n                return nums[mid+1]\n            elif nums[mid] > nums[-1]:\n                start = mid + 1\n            else:\n                end = mid - 1\n        \n        return nums[0]\n```\n\nPlease upvote if it was helpful :))
['Python']