当前位置:网站首页>Leetcode array question brushing notes
Leetcode array question brushing notes
2022-07-05 13:54:00 【Cwxh0125】
485. Maximum continuous 1 The number of
Given a binary array , Calculate the maximum continuity 1 The number of .
Ideas : Let's go through the array first , Use a variable count To record 1 The number of When I meet 1 Change quantity ++, If encountered 0 Return to zero . You also need to use a variable maxcount To record the maximum
Method 1
int findMaxConsecutiveOnes(int* nums, int numsSize){
int count=0,maxCount=0; // Define two variables
for(int i=0;i<numsSize ;i++){ // Traversal array
if(nums[i]==1) // if The value is 1 be count++
{count++;}
else {
maxCount=fmax(count,maxCount); // If zero is encountered Then make the current variable value and maxcount Compare the largest
count=0; // After zero send count Zero value
}
}
maxCount=fmax(count,maxCount);
return maxCount;
}
边栏推荐
- Attack and defense world web WP
- Can graduate students not learn English? As long as the score of postgraduate entrance examination English or CET-6 is high!
- Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications
- 昆仑太科冲刺科创板:年营收1.3亿拟募资5亿 电科太极持股40%
- Pancake Bulldog robot V2 (code optimized)
- 瑞能实业IPO被终止:年营收4.47亿 曾拟募资3.76亿
- Laravel框架运行报错:No application encryption key has been specified
- Matlab learning 2022.7.4
- 国富氢能冲刺科创板:拟募资20亿 应收账款3.6亿超营收
- ETCD数据库源码分析——rawnode简单封装
猜你喜欢

清大科越冲刺科创板:年营收2亿 拟募资7.5亿

Why do I support bat to dismantle "AI research institute"
![Primary code audit [no dolls (modification)] assessment](/img/b8/82c32e95d1b72f75823ca91c97138e.jpg)
Primary code audit [no dolls (modification)] assessment

RK3566添加LED

Laravel framework operation error: no application encryption key has been specified

Liar report query collection network PHP source code

Self built shooting range 2022

【公开课预告】:视频质量评价基础与实践

常见问题之PHP——Fatal error: Allowed memory size of 314572800 bytes exhausted...

Solve the problem of invalid uni app configuration page and tabbar
随机推荐
LeetCode_67(二进制求和)
JS takes key and value from an array object to form a new object
When there are too many input boxes such as input transmitted at one time in the form, the post data is intercepted
Self built shooting range 2022
redis6主从复制及集群
Request + BS4 crawl Netease cloud music popular comments
Controller in laravel framework
Blue Bridge Cup study 2022.7.5 (morning)
laravel-dompdf导出pdf,中文乱码问题解决
Network security - Novice introduction
Ueditor + PHP enables Alibaba cloud OSS upload
2022 construction welder (special type of construction work) special operation certificate examination question bank and online simulation examination
锚点导航小demo
Multi person cooperation project to see how many lines of code each person has written
MySQL get time
通讯录(链表实现)
Elfk deployment
NFT value and white paper acquisition
Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution
Jetpack Compose入门到精通