leetcode:485. 最大连续1的个数

在这里插入图片描述

class Solution {
   public int findMaxConsecutiveOnes(int[] nums) {
    	  int max=0;
    	  int count=0;
    	  for (int i : nums) {
			if(i==0) 
				count=0;
			else 
				count++;
			max=max>count?max:count;			
		}
		return max;
      }	
}

猜你喜欢

转载自blog.csdn.net/qq_42405666/article/details/89577559