【leetcode】485. Max Consecutive Ones
problem
solution1:
class Solution {
public:
int findMaxConsecutiveOnes(vector<int>& nums) {
if(nums.empty()) return ;
int ans = , max = INT_MIN;
for(int i=; i<nums.size(); i++)
{
if(nums[i]==) ans++;
else if(nums[i]!=)
{
if(max<ans) max = ans;
ans = ;
}
}
return max>ans ? max : ans;
}
};
参考
1. Leetcode_485. Max Consecutive Ones;
完
【leetcode】485. Max Consecutive Ones的更多相关文章
- 【LeetCode】485. Max Consecutive Ones 解题报告(Java & Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Java解法 Python解法 日期 [LeetCo ...
- 【LeetCode】487. Max Consecutive Ones II 解题报告 (C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 动态规划 日期 题目地址:https://leetco ...
- 【LeetCode】1004. Max Consecutive Ones III 解题报告(C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 虫取法/双指针 日期 题目地址:https://le ...
- 【leetcode】1004. Max Consecutive Ones III
题目如下: Given an array A of 0s and 1s, we may change up to K values from 0 to 1. Return the length of ...
- 【LeetCode】128. Longest Consecutive Sequence
Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest con ...
- 【LeetCode】149. Max Points on a Line 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典+最大公约数 日期 题目地址:https://l ...
- 【LeetCode】695. Max Area of Island 解题报告(Python & C++)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:DFS 方法二:BFS 日期 题目地址:ht ...
- 【LeetCode】363. Max Sum of Rectangle No Larger Than K 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/max-sum- ...
- 【LeetCode】768. Max Chunks To Make Sorted II 解题报告(Python)
作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/max-chun ...
随机推荐
- PHP基础入门(二)---入门基础知识必备
前言 在上一章中,我们初步了解了PHP的网页基础和PHP的入门基础,今天继续给大家分享更多有关PHP的知识. 理论知识看起来可能比较枯燥一些,但是我们的实践(敲代码)毕竟离不开它. 只有理论与实践相结 ...
- 小程序中data数据的处理方法总结(小程序交流群:604788754)
WXML: <view class="container"> <view wx:for="{{list}}" wx:key="thi ...
- Linux系统下apt-get命令无法安装常见软件包?
- maven的依赖特性
若排版紊乱可查看我的个人博客原文地址 maven的依赖特性很多很杂,这里大概总结一下,maven的依赖特性主要是依赖范围和传递依赖,前者会影响后者,这篇文章会介绍传递依赖的传递原则,出现冲突传递依赖默 ...
- Python 正则表达式相关问题
这几天学习python,写正则表达式相关代码如下: import re print(re.search(r'(?<=<(\w+)>).*(?=<\/\1>)'," ...
- angular 定时函数
注入$interval,$timeout 服务 2.定义函数 var aa = $interval(function(){ $timout(function(){ ..... }) },,定时时间 ...
- Spring Cloud的应用程序—上下文服务
Spring Boot对于如何使用Spring构建应用程序有一个看法:例如它具有常规配置文件的常规位置,以及用于常见管理和监视任务的端点.Spring Cloud建立在此之上,并添加了一些可能系统中所 ...
- SpringMVC云题库错题及答案汇总-2
此题目考察的是SpringMVC-注解驱动控制器,注释类型的范围: A.处理requet uri 部分的注解: @PathVariable; B.处理request header部分的注解: @Req ...
- Ruby中方法的设计理念
Ruby中的方法命名遵从与局部变量相同的规则和约定.这是一种设计理念:方法并不因其自身作为方法而被人关注,而是简单地作为提供值的表达式融入到程序的结构中.
- zookeeper 启动 zookeeper_server.pid: Permission denied
在启动zookeeper的时候 报错 没有权限 以为是 zookeeper 没有权限 然后 chmod -R 777 zookeeper/ 之后还是不行. 后来 才发现 原来是我 /tmp/zooke ...