当前位置:网站首页>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
边栏推荐
- Open Inventor 10.12 重大改进--和谐版
- TensorRT安装及使用教程「建议收藏」
- endnote引用
- [Niu Ke brush questions - SQL big factory interview questions] NO3. E-commerce scene (some east mall)
- Istio微服务治理网格的全方面可视化监控(微服务架构展示、资源监控、流量监控、链路监控)
- 浏览器被hao360劫持解决办法
- 六石编程学:不论是哪个功能,你觉得再没用,会用的人都离不了,所以至少要做到99%
- 清除浮动的四种方式及其原理理解
- ICML2022 | Fully Granular Self-Semantic Propagation for Self-Supervised Graph Representation Learning
- MATLAB | 我也做了一套绘图配色可视化模板
猜你喜欢
随机推荐
文本相似度计算(中英文)详解实战
PHP序列化:eval
基于模糊预测与扩展卡尔曼滤波的野值剔除方法
ECCV 2022 | Robotic Interaction Perception and Object Manipulation
How to quickly split and merge cell data in Excel
关于MySQL主从复制的数据同步延迟问题
golang-gin-pprof-使用以及安全问题
ICML2022 | Fully Granular Self-Semantic Propagation for Self-Supervised Graph Representation Learning
C# List用法 List介绍
ASM module in SAP Ecommerce Cloud Spartacus UI and Accelerator UI
hyperf的启动源码分析(二)——请求如何到达控制器
Introduction to using NPM
PHP Serialization: eval
numpy矩阵和向量的保存与加载,以及使用保存的向量进行相似度计算
C#Assembly的使用
Sliding window method to segment data
基于神经网络的多柔性梁耦合结构振动控制
JSP中如何借助response对象实现页面跳转呢?
Hard disk partition, expand disk C, no reshipment system, not heavy D dish of software full tutorial.
VU 非父子组件通信









