knakul853

Untitled

Jul 17th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. /*
  2. knakul853
  3. */
  4. class Solution {
  5. public:
  6.     int findMaxConsecutiveOnes(vector<int>& nums) {
  7.         int ans=0;
  8.       int ct=0;
  9.       int l = nums.size();
  10.       for(int i=0;i<l;i++)
  11.       {
  12.        
  13.         if(nums[i]==1)
  14.         {
  15.           ct++;
  16.         }
  17.         else
  18.         {ct=0;}
  19.         ans=max(ans,ct);
  20.       }
  21.       return ans;
  22.     }
  23. };
Add Comment
Please, Sign In to add comment