当前位置:网站首页>leetcode:485.最大连续 1 的个数
leetcode:485.最大连续 1 的个数
2022-07-31 13:41:00 【心软且酷丶】
难度:简单
给定一个二进制数组
nums, 计算其中最大连续1的个数。示例 1:
输入:nums = [1,1,0,1,1,1] 输出:3 解释:开头的两位和最后的三位都是连续 1 ,所以最大连续 1 的个数是 3.示例 2:
输入:nums = [1,0,1,1,0,1] 输出:2提示:
1 <= nums.length <= 10ⁿ- n = 5
nums[i]不是0就是1.题解:
class Solution: def findMaxConsecutiveOnes(self, nums: List[int]) -> int: Count = 0 Max = 0 for i in nums: if i == 1: Count += 1 Max = max(Max,Count) if i == 0: Count = 0 return Max
边栏推荐
- How IDEA runs web programs
- LeetCode只出现一次的数字
- 报错:npm ERR code EPERM
- Save and load numpy matrices and vectors, and use the saved vectors for similarity calculation
- ECCV 2022 | Robotic Interaction Perception and Object Manipulation
- The use of C# control CheckBox
- 求一份常见Oracle故障模拟场景
- Spark学习:为Spark Sql添加自定义优化规则
- 【蓝桥杯选拔赛真题46】Scratch磁铁游戏 少儿编程scratch蓝桥杯选拔赛真题讲解
- Spark Learning: Add Custom Optimization Rules for Spark Sql
猜你喜欢

深入浅出边缘云 | 4. 生命周期管理

C#控件StatusStrip使用

PartImageNet物体部件分割(Semantic Part Segmentation)数据集介绍

How to quickly split and merge cell data in Excel

The use of C# control CheckBox

networkx绘制度分布

报错:npm ERR code EPERM

PHP Serialization: eval

C# Get network card information NetworkInterface IPInterfaceProperties

拥塞控制,CDN,端到端
随机推荐
Verilog——基于FPGA的贪吃蛇游戏(VGA显示)
C#控件ListView用法
The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
技能大赛训练题:MS15_034漏洞验证与安全加固
全局平均池化层替代全连接层(最大池化和平均池化的区别)
为什么 wireguard-go 高尚而 boringtun 孬种
ECCV2022: Recursion on Transformer without adding parameters and less computation!
matlab as(assert dominance)
Batch大小不一定是2的n次幂!ML资深学者最新结论
C#Assembly的使用
LeetCode·304竞赛·6132·使数组中所有元素都等于零·模拟·哈希
numpy矩阵和向量的保存与加载,以及使用保存的向量进行相似度计算
Flutter键盘可见性
MATLAB | 我也做了一套绘图配色可视化模板
How IDEA runs web programs
Selenium IDE for Selenium Automation Testing
DELL SC compellent 康贝存储系统怎么抓取配置信息
技能大赛dhcp服务训练题
Usage of += in C#
C语言基础练(九九乘法表)与打印不同星号图案