485. Max Consecutive Ones
来源:互联网 发布:农村淘宝发展现状分析 编辑:程序博客网 时间:2024/04/23 21:17
原题
Given a binary array, find the maximum number of consecutive 1s in this array.
Example 1:
Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3.
代码实现
public int FindMaxConsecutiveOnes(int[] nums) { int ito1=0; int max = 0; foreach(var item in nums){ if(item==1){ ito1++; if(max<ito1) max = ito1; } else ito1=0; } return max; }
leetcode-solution库
leetcode算法题目解决方案每天更新在github库中,欢迎感兴趣的朋友加入进来,也欢迎star,或pull request。https://github.com/jackzhenguo/leetcode-csharp
2 0
- 485. Max Consecutive Ones*
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485.Max Consecutive Ones
- httpclient3与httpclient4访问的一些区别
- Android Studio如何导入android-support-v4,v7,v13等支持包?
- 用U盘安装ESXI5.5(亲测)--Rufus工具
- 【算法】程序猿不写代码是不对的49
- 让eclipse-CDT识别c++11 新容器
- 485. Max Consecutive Ones
- CSS边框长度控制
- tcpdump抓包
- 1. 初识FFmpeg
- Android TabLayout的使用(ViewPager添加标题)
- 使用jxls2.X导出excel文件
- 线上和线下营销有“隔阂”?三大交融妙招助力效益最大化!
- 如何在Windows下开发Python
- Java学习之使用集合实现对字符串中元素指定格式输出