如题目: 回传最长连续的1
In: binary array nums
Out: the maximum number of consecutive 1
's in the array
class Solution:
def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
maxLen = 0
tmpLen = 0
for i in nums:
if i == 1:
tmpLen+=1
maxLen=max(maxLen,tmpLen)
else:
tmpLen=0
return maxLen
class Solution {
public int findMaxConsecutiveOnes(int[] nums) {
int tmpLen = 0;
int maxLen = 0;
for(int i=0;i<nums.length;i++)
{
if(nums[i]==1)
{
tmpLen++;
maxLen=Math.max(tmpLen,maxLen);
}
else
{
tmpLen=0;
}
}
return maxLen;
}
}
Easy
前言 在前一天介绍了 Docker 容器操作的技巧,今天来透过 Lab 学习如何将专案建置成 Ima...
前言 该系列是为了让看过Vue官方文件或学过Vue但是却不知道怎麽下手去重构现在有的网站而去规画的系...
前言: 关於前面mlmodel的部分还没搞定 事先测试了一下CoreML的功能 VC程序码: imp...
目前我最想先学习的程序语言是python,因为我现在大三在许多课程都会优先使用这个语言,如深度学习中...