leetcode 485. Max Consecutive Ones

来源:互联网 发布:手机反监控软件 编辑:程序博客网 时间:2024/05/16 19:00
/** * leetcode 485. Max Consecutive Ones * @param nums * @return * 2017年2月28日下午3:39:21 */public int findMaxConsecutiveOnes(int[] nums) {        int maxLen = 0;int count = 0;for (int i = 0; i < nums.length; i++) {if(nums[i] == 1) {count++;}else{if(maxLen<=count)maxLen = count;count = 0;}}if(maxLen<=count)maxLen = count;return maxLen;    }

0 0