Leetcode #485 Max Consecutive Ones
来源:互联网 发布:gta5 handling原数据 编辑:程序博客网 时间:2024/06/03 17:09
Description
Given a binary array, find the maximum number of consecutive 1s in this array.
Note
- The input array will only contain 0 and 1.
- The length of input array is a positive integer and will not exceed 10,000
Example
Input: [1,1,0,1,1,1]
Output: 3
Explanation: The first two digits or the last three digits are consecutive 1s.
The maximum number of consecutive 1s is 3.
Code
class Solution(object): def findMaxConsecutiveOnes(self, nums): """ :type nums: List[int] :rtype: int """ cnt = 0 maxn = 0 for i in nums: if i == 1: cnt += 1 maxn = max(maxn, cnt) else: cnt = 0 return maxn
0 0
- [LeetCode]485 Max Consecutive Ones
- [leetcode-485]Max Consecutive Ones
- [Leetcode 485 ]Max Consecutive Ones
- Leetcode 485 Max Consecutive Ones
- leetcode-485-Max Consecutive Ones
- leetcode 485 Max Consecutive Ones
- LeetCode 485 --- Max Consecutive Ones
- Leetcode #485 Max Consecutive Ones
- Leetcode 485 Max Consecutive Ones
- 【LeetCode】485 Max Consecutive Ones
- LeetCode-485 Max Consecutive Ones
- Max Consecutive Ones[LeetCode 485]
- LEETCODE--Max Consecutive Ones
- LeetCode: Max Consecutive Ones
- 【leetcode】Max Consecutive Ones
- LeetCode:Max Consecutive Ones
- LeetCode Max Consecutive Ones
- LeetCode Max Consecutive Ones
- React Native组件生命周期
- static关键字
- Introduction to A*
- YuiCompress静态资源压缩详解
- java ArrayList遍历时删除元素
- Leetcode #485 Max Consecutive Ones
- JavaWeb读取本地json文件以及乱码问题解决
- JavaScript中的this关键字的用法和注意点
- 【数据结构郝斌】3、模块一:线性结构
- sublime text 3 c++ 运行时解决cin输入问题( ubuntu)
- TCP协议学习笔记
- Delta3d组件以及消息机制
- C到C++的升级
- [学习心得]ASP.NET比较验证控件