3 lines simple c++ code, 3ms


  • 0
    B
    class Solution {
    public:
        int findMin(vector<int>& nums) {
            int n = nums.size();
            for(int i = 0; i < n -1 ; i++)
                if(nums[i] > nums[i+1]) return nums[i+1];
            return nums[0];
        }
    };
    

Log in to reply
 

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