class Solution { public: int pivot(vector<int> nums) { int n=nums.size(); int s=0, l=n-1; int mid=s+(l-s)/2; while(s<=l) { if(s==l) return s; if(nums[mid]>nums[n-1]) s=mid+1; else l=mid; mid=s+(l-s)/2; } return s; } int findMin(vector<int>& nums) { int ans=nums[pivot(nums)]; return ans; } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter