🚀 100% | 0 ms 👏🏻 | Simple solution with explanation using binary search
Intuition\nThe intuition behind this solution is to use binary search to find the minimum element in the rotated array. By comparing the middle element with the
# Intuition\nThe intuition behind this solution is to use binary search to find the minimum element in the rotated array. By comparing the middle element with the element at the end of the array, we can determine which half of the array to focus on.\n\n# Approach\n1. Initialize two pointers, start at the beginning of the array and end at the end of the array.\n2. Use a while loop to iterate until start is less than end.\n3. Calculate the middle index mid.\n4. If the element at mid is greater than the element at end, set start to mid + 1 (as the minimum element is on the right side).\n5. If the element at mid is less than or equal to the element at end, set end to mid (as the minimum element is on the left side or is the element at mid).\n6. Continue the loop until start equals end.\n7. Return the value of nums[start] as it represents the minimum element.\n\n# Complexity\n- Time complexity: O(log(n))\n\n- Space complexity: O(1)\n\n# Code\n```\nclass Solution {\npublic:\n    int findMin(vector<int>& nums) {\n        int start=0,end=nums.size()-1;\n        \n        while(start<end){\n            int mid=start+(end-start)/2;\n            if(nums[mid]>nums[end]) start = mid+1;\n            else end = mid;\n        }\n\n        return nums[start];\n    }\n};\n```
['Binary Search', 'C++']