当前位置:网站首页>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
边栏推荐
- Verilog——基于FPGA的贪吃蛇游戏(VGA显示)
- 生产力工具和插件
- Usage of += in C#
- 对数字化时代的企业来说,数据治理难做,但应该去做
- ICML2022 | Fully Granular Self-Semantic Propagation for Self-Supervised Graph Representation Learning
- C#使用NumericUpDown控件
- Selenium IDE for Selenium Automation Testing
- P5019 [NOIP2018 提高组] 铺设道路
- 模拟量差分和单端(iou计算方法)
- An article makes it clear!What is the difference and connection between database and data warehouse?
猜你喜欢
随机推荐
新款现代帕里斯帝预售开启,安全、舒适一个不落
报错IDEA Terminated with exit code 1
Samba 远程命令执行漏洞(CVE-2017-7494)
拥塞控制,CDN,端到端
Solution for browser hijacking by hao360
基于神经网络的多柔性梁耦合结构振动控制
pytorch gpu版本安装最新
selenium被反爬了怎么办?
49.【拷贝构造函数与重载】
20.nn.Module
动作捕捉系统用于柔性机械臂的末端定位控制
Shell项目实战1.系统性能分析
CodeIgniter 打开错误日志
LeetCode·304竞赛·6132·使数组中所有元素都等于零·模拟·哈希
报错:npm ERR code EPERM
模拟量差分和单端(iou计算方法)
Verilog——基于FPGA的贪吃蛇游戏(VGA显示)
MATLAB | 我也做了一套绘图配色可视化模板
浏览器被hao360劫持解决办法
Error: npm ERR code EPERM









