Max Consecutive Ones
LeetCode題目: 485. Max Consecutive Ones
My solution:
/**
* @param {number[]} nums
* @return {number}
*/
let findMaxConsecutiveOnes = nums => {
let max = 0, count = 0;
for(let i=0; i<nums.length; i++) {
if(nums[i] === 1) count++;
else {
max = Math.max(max, count);
count = 0;
}
}
return Math.max(max, count);
};
