Given a binary array, find the maximum number of consecutive 1s in this array.
class Solution {
public:
int findMaxConsecutiveOnes(vector<int>& nums) {
int sum1 = 0;
int tmp = 0;
for (int i=0; i<nums.size(); i++) {
if (nums[i]==1) {
tmp++;
}else{
tmp = 0;
}
sum1 = max(tmp, sum1);
}
return sum1;
}
};