Very simple O(n) solution


  • 0
    T
    class Solution {
    public:
        int findMin(vector<int>& nums) {
            int i = 0, l = nums.size();
            do {
                i = (i+1) % l;
            } while (nums[i % l] <= nums[(i+1) % l] && i);
            return nums[(i+1) % l];
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.