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);
}
}
// %90.94 %95.10
leetcode No.485最大连续1的个数
最新推荐文章于 2022-12-18 17:51:12 发布