当前位置:网站首页>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
边栏推荐
猜你喜欢

The operator,

ECCV 2022 | Robotic Interaction Perception and Object Manipulation

ECCV2022: Recursion on Transformer without adding parameters and less computation!

How IDEA runs web programs

STM32的CAN过滤器

A detailed explanation of the usage of Async and Await in C#

关于MySQL主从复制的数据同步延迟问题

Reasons and solutions for Invalid bound statement (not found)

八大排序汇总及其稳定性

3.爬虫之Scrapy框架1安装与使用
随机推荐
P5019 [NOIP2018 提高组] 铺设道路
Batch大小不一定是2的n次幂!ML资深学者最新结论
49.【拷贝构造函数与重载】
清除浮动的四种方式及其原理理解
Introduction to the PartImageNet Semantic Part Segmentation dataset
uniapp微信小程序引用标准版交易组件
C# control ToolStripProgressBar usage
IDEA如何运行web程序
C# List用法 List介绍
Invalid bound statement (not found)出现的原因和解决方法
pytorch gpu版本安装最新
C#Assembly的使用
推荐系统-召回阶段-2013:DSSM(双塔模型)【Embedding(语义向量)召回】【微软】
golang-gin - graceful restart
golang-gin-pprof-使用以及安全问题
sqlalchemy determines whether a field of type array has at least one consistent data with an array
线程池的使用二
csdn发文助手问题
Save and load numpy matrices and vectors, and use the saved vectors for similarity calculation
C# control ListView usage