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

mac2024-05-29  32

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
最新回复(0)