力扣 485. 最大连续 1 的个数 难度:简单

题目地址:https://leetcode-cn.com/problems/max-consecutive-ones/

我的题解:

class Solution {     public int findMaxConsecutiveOnes(int[] nums) {         int max = 0;         int curMax = 0;         for(int i=0;i<nums.length;i++){             if(nums[i]==1){                 curMax +=1;                 if(i==nums.length-1){                      if(curMax>max){                         max = curMax;                      }                 }             }else{                 if(curMax>max){                     max = curMax;                 }                 //当前连续输清零                 curMax = 0;             }         }         return max;     } }
上一篇:多串口服务器的DCS485多主机通讯


下一篇:kaggle比赛实践M5-baseline研读