JAVA_Max Consecutive Ones_LeetCode 485


JAVA_Max Consecutive Ones_LeetCode 485

JAVA_Max Consecutive Ones_LeetCode 485 풀이 class Solution { public int findMaxConsecutiveOnes(int[] nums) { int max=0 ,cnt =0; for(int n : nums) max=Math.max(max,cnt = n == 0 ? 0 : cnt+1); return max; } } * 출처 Max Consecutive Ones - LeetCode Max Consecutive Ones - Given a binary array nums, return the maximum number of consecutive 1's in the array. Example 1: Input: nums = [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of ...


#JAVA #JAVA_LeetCode485 #JAVA_MaxConsecutiveOnes #JAVA_MaxConsecutiveOnes_LeetCode485 #MaxConsecutiveOnes_LeetCode485

원문링크 : JAVA_Max Consecutive Ones_LeetCode 485