leetcode

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

0485.cpp (283B)


      1 class Solution {
      2   public:
      3     int findMaxConsecutiveOnes(vector<int> &nums) {
      4         int maxi = 0;
      5         int cnt = 0;
      6 
      7         for (int i : nums)
      8             if (i)
      9                 maxi = max(maxi, ++cnt);
     10             else
     11                 cnt = 0;
     12 
     13         return maxi;
     14     }
     15 };