代码:
class Solution {
public int findMaxConsecutiveOnes(int[] nums) {
int count = 0;
int maxContinue = 0;
for(int i = 0;i < nums.length;i ++){
if(nums[i] == 1){
count ++;
}else{
maxContinue = count > maxContinue ? count : maxContinue;
count = 0;
}
}
return count > maxContinue ? count : maxContinue;
}
}
结果: