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)


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