给定一个二进制数组, 计算其中最大连续 1 的个数。
class Solution{
public int findMaxConsecutiveOnes(int[] nums){
int count = 0;
int maxCount = 0;
for(int i = 0;i < nums.length; i++){
if (nums[i] == 1){
count++;
} else {
maxCount = Math.max(count, maxCount);
count = 0;
}
}
return Math.max(count, maxCount);
}
}