美文网首页
485. Max Consecutive Ones

485. Max Consecutive Ones

作者: hyhchaos | 来源:发表于2017-01-15 21:48 被阅读24次

    Java

    public class Solution {
        public int findMaxConsecutiveOnes(int[] nums) {
            int count=0;
            int result=0;
            for(int i=0;i<nums.length;i++)
            {
                if(nums[i]==1)
                {
                count++;
                result=result<count?count:result;
                }
                else
                {
                count=0;
                }
            }
            return result;
        }
    }
    

    相关文章

      网友评论

          本文标题:485. Max Consecutive Ones

          本文链接:https://www.haomeiwen.com/subject/agrubttx.html