当前位置:网站首页>leetcode: 485. Maximum number of consecutive 1s
leetcode: 485. Maximum number of consecutive 1s
2022-07-31 13:46:00 【Soft-hearted and cool】
Difficulty: Easy
Given a binary array
nums, calculate the maximum number of consecutive1in it.Example 1:
Input:nums = [1,1,0,1,1,1]Output:3Explanation: The first two and the last three are consecutive 1s, so the maximum number of consecutive 1s is 3.Example 2:
Input:nums = [1,0,1,1,0,1]Output:2Tip:
1 <= nums.length <= 10ⁿ- n = 5
nums[i]is either0or1.Solution:
class Solution:def findMaxConsecutiveOnes(self, nums: List[int]) -> int:Count = 0Max = 0for i in nums:if i == 1:Count += 1Max = max(Max,Count)if i == 0:Count = 0return Max
边栏推荐
猜你喜欢

go使用makefile脚本编译应用

C#获得网卡信息 NetworkInterface IPInterfaceProperties

【蓝桥杯选拔赛真题46】Scratch磁铁游戏 少儿编程scratch蓝桥杯选拔赛真题讲解

技能大赛训练题:登录安全加固

4.爬虫之Scrapy框架2数据解析&配置参数&数据持久化&提高Scrapy效率

Spark学习:为Spark Sql添加自定义优化规则

ECCV 2022 | Robotic Interaction Perception and Object Manipulation

Selenium自动化测试之Selenium IDE

Network layer key protocol - IP protocol

LeetCode·304竞赛·6132·使数组中所有元素都等于零·模拟·哈希
随机推荐
尚硅谷-JVM-内存和垃圾回收篇(P1~P203)
MySQL玩到这种程度,难怪大厂抢着要!
The use of C# control CheckBox
TensorRT安装及使用教程「建议收藏」
Invalid bound statement (not found)出现的原因和解决方法
PartImageNet物体部件分割(Semantic Part Segmentation)数据集介绍
C# Get network card information NetworkInterface IPInterfaceProperties
/run/NetworkManager占用空间过大
六石编程学:不论是哪个功能,你觉得再没用,会用的人都离不了,所以至少要做到99%
MATLAB | 我也做了一套绘图配色可视化模板
Samba 远程命令执行漏洞(CVE-2017-7494)
深度剖析 Apache EventMesh 云原生分布式事件驱动架构
LeetCode只出现一次的数字
Selenium自动化测试之Selenium IDE
SAP e-commerce cloud Spartacus SSR Optimization Engine execution sequence of several timeouts
为什么 wireguard-go 高尚而 boringtun 孬种
技能大赛训练题:域用户和组织单元的创建
技能大赛训练题: 子网掩码划分案例
图像大面积缺失,也能逼真修复,新模型CM-GAN兼顾全局结构和纹理细节
Usage of += in C#