首页 > 学院 > 开发设计 > 正文

LeetCode 485 --- Max Consecutive Ones

2019-11-08 02:17:26
字体:
来源:转载
供稿:网友

题目链接: LeetCode 485 — Max Consecutive Ones

AC代码:

public class PRoblem485 { public static void main(String[] args) { // TODO Auto-generated method stub int[] name={1,1,0,1,1,1}; System.out.println(findMaxConsecutiveOnes(name)); } public static int findMaxConsecutiveOnes(int[] nums) { int l=0; int max=0; for(int i=0;i<nums.length;i++){ if(nums[i]==1){ l++; if(l>max) max=l; } else{ l=0; continue; } } return max; }}
上一篇:1009时钟

下一篇:Redis设置认证的密码

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表