当前位置:网站首页>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 consecutive1
in 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 either0
or1.
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
边栏推荐
- How to quickly split and merge cell data in Excel
- 0X7FFFFFFF,0X80000000「建议收藏」
- IDEA如何运行web程序
- ICML2022 | Fully Granular Self-Semantic Propagation for Self-Supervised Graph Representation Learning
- 报错:npm ERR code EPERM
- Shell项目实战1.系统性能分析
- networkx绘制度分布
- 报错IDEA Terminated with exit code 1
- PartImageNet物体部件分割(Semantic Part Segmentation)数据集介绍
- The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
猜你喜欢
[Niu Ke brush questions - SQL big factory interview questions] NO3. E-commerce scene (some east mall)
Even if the image is missing in a large area, it can also be repaired realistically. The new model CM-GAN takes into account the global structure and texture details
Batch大小不一定是2的n次幂!ML资深学者最新结论
技能大赛训练题:ftp 服务攻防与加固
endnote引用
An article makes it clear!What is the difference and connection between database and data warehouse?
PartImageNet物体部件分割(Semantic Part Segmentation)数据集介绍
使用NVM进行node版本切换管理
How to quickly split and merge cell data in Excel
尚硅谷-JVM-内存和垃圾回收篇(P1~P203)
随机推荐
技能大赛训练题:ftp 服务攻防与加固
如何使用StarUML画类图[通俗易懂]
对数字化时代的企业来说,数据治理难做,但应该去做
Solution for browser hijacking by hao360
PartImageNet物体部件分割(Semantic Part Segmentation)数据集介绍
C# using NumericUpDown control
CLion用于STM32开发
机器学习模型验证:被低估的重要一环
C#使用NumericUpDown控件
Spark Learning: Add Custom Optimization Rules for Spark Sql
Shell脚本经典案例:文件的备份
The batch size does not have to be a power of 2!The latest conclusions of senior ML scholars
技能大赛训练题: 子网掩码划分案例
C# control StatusStrip use
Istio微服务治理网格的全方面可视化监控(微服务架构展示、资源监控、流量监控、链路监控)
C# 中的Async 和 Await 的用法详解
All-round visual monitoring of the Istio microservice governance grid (microservice architecture display, resource monitoring, traffic monitoring, link monitoring)
go使用makefile脚本编译应用
八大排序汇总及其稳定性
A detailed explanation of the usage of Async and Await in C#