Created
January 16, 2018 13:40
-
-
Save s4553711/e9cf1c4fcd1546e6fcc64d1d7d4b3030 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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