当前位置:网站首页>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;
}
边栏推荐
- ELFK部署
- PHP generate Poster
- What is information security? What is included? What is the difference with network security?
- 昆仑太科冲刺科创板:年营收1.3亿拟募资5亿 电科太极持股40%
- [js] basic syntax - for loop
- 锚点导航小demo
- Internal JSON-RPC error. {"code":-32000, "message": "execution reverted"} solve the error
- redis6主从复制及集群
- 这18个网站能让你的页面背景炫酷起来
- PostgreSQL Usage Summary (PIT)
猜你喜欢

Redis6 transaction and locking mechanism

Kotlin collaboration uses coroutinecontext to implement the retry logic after a network request fails
![Primary code audit [no dolls (modification)] assessment](/img/b8/82c32e95d1b72f75823ca91c97138e.jpg)
Primary code audit [no dolls (modification)] assessment

About the problem and solution of 403 error in wampserver

In addition to the root directory, other routes of laravel + xampp are 404 solutions

Why do I support bat to dismantle "AI research institute"
![[machine learning notes] several methods of splitting data into training sets and test sets](/img/f6/eca239bb4b1764a1495ccd9a868ec1.jpg)
[machine learning notes] several methods of splitting data into training sets and test sets

瑞能实业IPO被终止:年营收4.47亿 曾拟募资3.76亿

Recommendation number | what are interesting people looking at?

The real king of caching, Google guava is just a brother
随机推荐
Solve the problem of invalid uni app configuration page and tabbar
金融壹账通香港上市:市值63亿港元 叶望春称守正笃实,久久为功
Wonderful express | Tencent cloud database June issue
RK3566添加LED
uplad_ Labs first three levels
Jasypt configuration file encryption | quick start | actual combat
[js] basic syntax - for loop
Selenium crawls Baidu pictures
网络安全-HSRP协议
Programmer growth Chapter 8: do a good job of testing
kafaka 日志收集
Could not set property 'ID' of 'class xx' with value 'XX' argument type mismatch solution
Liar report query collection network PHP source code
[cloud resources] what software is good for cloud resource security management? Why?
【云资源】云资源安全管理用什么软件好?为什么?
Routing in laravel framework
Laravel dompdf exports PDF, and the problem of Chinese garbled code is solved
Aikesheng sqle audit tool successfully completed the evaluation of "SQL quality management platform grading ability" of the Academy of communications and communications
这18个网站能让你的页面背景炫酷起来
2022建筑焊工(建筑特殊工种)特种作业证考试题库及在线模拟考试