Skip to content

Instantly share code, notes, and snippets.

@s4553711
Created January 16, 2018 13:40
Show Gist options
  • Save s4553711/e9cf1c4fcd1546e6fcc64d1d7d4b3030 to your computer and use it in GitHub Desktop.
Save s4553711/e9cf1c4fcd1546e6fcc64d1d7d4b3030 to your computer and use it in GitHub Desktop.
class Solution {
public:
int findMaxConsecutiveOnes(vector<int>& nums) {
int max=0,cur=0;
for(int i=0;i<nums.size();i++) {
if(nums[i]&1) {
max=max>++cur?max:cur;
} else cur=0;
}
return max;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment