LeetCode
来源:互联网 发布:java导出excel表格poi 编辑:程序博客网 时间:2024/06/15 04:43
原题网址:
https://leetcode.com/problems/max-consecutive-ones/#/description
Given a binary array, find the maximum number of consecutive 1s in this array.
Example 1:
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.
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
题解: 无
代码:
class Solution(object): def findMaxConsecutiveOnes(self, nums): """ :type nums: List[int] :rtype: int """ count = 0 maxcount = 0 for item in nums: if(item==1): count += 1 else: if maxcount<count: maxcount = count count = 0 if maxcount<count: maxcount = count return maxcount
阅读全文
0 0
- leetcode
- [leetcode]
- LeetCode
- leetcode
- leetcode
- leetcode:
- leetcode:
- LeetCode
- leetcode
- LEETCODE
- leetcode
- leetCode
- leetcode
- [leetcode]
- LeetCode
- leetcode
- leetcode:
- leetcode
- Weex新建项目报错weex-vue-render/index.js
- java 给线程池改名字的作用
- android项目的JaCoCo代码覆盖率入门使用
- py-faster-rcnn_cuda8.0_cudnn5.0_报错
- cvNamedWindow与namedWindow,cvShowImage与inshow的区别
- LeetCode
- tcpdf导入官方示例报错解决方案
- Java 自动识别对象属性有无改变
- UICollectionView创建头部headerview
- android studio 编译C生成.so文件
- SpringMVC的几种返回方式
- 高斯混合背景建模
- golang通道中 nil通道 close通道的特性点
- Materail Design 入门(九)—— NavigationView的使用