O(n) C++ solution


  • 0
    A
    int findMin(vector<int>& nums) {
            int min = nums.at(0);
            for(int i=0; i<nums.size(); i++)
                if(nums.at(i)<min)
                    min = nums.at(i);
            return min;        
        }
    

Log in to reply
 

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