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;
}
};
C++ solution with O(n)


@shawn49
the same as following code:
if(nums[i]==1)
{
cur = cur +1;
if(max<=cur)
{
max = cur;
}
}

@Tandy123 Thank you very much!
After your explaining, I feel the code is very concise and clear
so
we can also write as:
if (max<++cur) { // ++cur > cur+=1; but it compress the code into one line. max=cur }
