力扣485 最大连续1的个数

class Solution {
    public int findMaxConsecutiveOnes(int[] nums) {
   
    if(nums == null || nums.length ==0){   //判断数组是否为空
        return 0;
    }
    int consecutive_ones =nums[0] ==1? 1 : 0; //定义max变量 如果开头元素为1 则赋值1 不是 赋值0
    int max =consecutive_ones;               
    for(int i=1 ;i

你可能感兴趣的:(leetcode,算法,散列表)