problem

485. Max Consecutive Ones

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的更多相关文章

  1. 【LeetCode】485. Max Consecutive Ones 解题报告(Java & Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 Java解法 Python解法 日期 [LeetCo ...

  2. 【LeetCode】487. Max Consecutive Ones II 解题报告 (C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客:http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 动态规划 日期 题目地址:https://leetco ...

  3. 【LeetCode】1004. Max Consecutive Ones III 解题报告(C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 虫取法/双指针 日期 题目地址:https://le ...

  4. 【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 ...

  5. 【LeetCode】128. Longest Consecutive Sequence

    Longest Consecutive Sequence Given an unsorted array of integers, find the length of the longest con ...

  6. 【LeetCode】149. Max Points on a Line 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典+最大公约数 日期 题目地址:https://l ...

  7. 【LeetCode】695. Max Area of Island 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 方法一:DFS 方法二:BFS 日期 题目地址:ht ...

  8. 【LeetCode】363. Max Sum of Rectangle No Larger Than K 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/max-sum- ...

  9. 【LeetCode】768. Max Chunks To Make Sorted II 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址: https://leetcode.com/problems/max-chun ...

随机推荐

  1. Daily record-December

    December 11. All circles have the same shape. 所有圆的形状都是相同的.2. She first drew a circle on the board. 她 ...

  2. 华为S5700设置vlan,并绑定电脑的IP地址与mac地址。

    要求是设置两个vlan,10和20.交换机下的10网段和20网段的电脑在两个vlan当中.20网段的ip地址与mac地址绑定,从而实现下面的电脑更改ip地址或者不明来源的电脑不能连接到交换机. 1.s ...

  3. Unity配置安卓开发环境

    1. 首先要安装JDK,从网上下载即可,我用的版本如下图 注意:此时要保存JDK的路径信息,后面需要使用2. 配置环境变量,计算机右键点属性->高级->环境变量3. 在系统中新建环境变量 ...

  4. Python-接口自动化(四)

    python基础知识(四) (四)处理文件 a.文件的格式主要有txt.html.xml,接下来主要讲的是txt格式的文件处理 对文件进行读写等操作会用到的函数是open(),第一个参数file是指传 ...

  5. 使用VirtualBox把IMG文件转换为VDI文件

    使用VirtualBox把IMG文件转换为VDI文件 首先确保已安装VirtualBox. 需要使用的命令: 语法:$ VBoxManage convertdd input.img output.vd ...

  6. windwos安装docker步骤

    参考 https://www.linuxidc.com/Linux/2016-07/133506.htm

  7. Android串口屏(电阻,电容触摸),带AV输入,7寸LCD1(800*48...

    基本参数:CPU:MT6572 双核1GHzRAM:512MB存储:4GB网络:GSM,WCDMA(BAND1)WIFI:2.4G 802.11bgn蓝牙:2.0支持GPS定位 扩展参数:1.电源输入 ...

  8. 20. Valid Parentheses ★

    题目内容: Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if th ...

  9. egret 简单的一笔画算法,在wing中可以直接跑(以后玩这类游戏就有个作弊器了)

    /** * 在Main中创建游戏场景 * Create a game scene */ private createGameScene() { MtwGame.Instance.init(this.s ...

  10. springmvc初始化失败问题跟踪

    1.问题 访问路径http://10.118.30.52:8088/helloWorld/hello后会报404错误,原因是springmvc配置文件中的包扫描路径错误.修改配置如下: <con ...