Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- knakul853
- */
- class Solution {
- public:
- int findMaxConsecutiveOnes(vector<int>& nums) {
- int ans=0;
- int ct=0;
- int l = nums.size();
- for(int i=0;i<l;i++)
- {
- if(nums[i]==1)
- {
- ct++;
- }
- else
- {ct=0;}
- ans=max(ans,ct);
- }
- return ans;
- }
- };
Add Comment
Please, Sign In to add comment