leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

0153.cpp (403B)


0 class Solution { 1 public: 2 int findMin(vector<int> &nums) { 3 int low = 0, high = nums.size() - 1; 4 while (low < high) { 5 if (nums[low] < nums[high]) return nums[low]; 6 int mid = low + (high - low) / 2; 7 if (nums[mid] >= nums[low]) 8 low = mid + 1; 9 else 10 high = mid; 11 } 12 return nums[low]; 13 } 14 };