class Solution {
public int findMaxConsecutiveOnes(int[] nums
) {
int result
=0,curLength
=0;
for(int i
=0;i
<nums
.length
;i
++){
if(nums
[i
]==1){
curLength
++;
}else{
result
=Math
.max(result
,curLength
);
curLength
=0;
}
}
return Math
.max(result
,curLength
);
}
}
转载请注明原文地址: https://mac.8miu.com/read-492864.html