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. WinForm界面设计优化过程

    以在做的项目为例,记录一下界面美化过程中遇到的问题,由于项目是先做出来之后,又请美工进行稍微调整设计界面,所以会又些限制 1. TabControl的问题----在添加了背景图片后,TabContro ...

  2. react .net core 发布 Access-Control-Allow-Origin Cors

    本案例用IIS部署 1. 在react上先publish: npm run build 生成了build文件,在此文件里添加web.config,注意httpProtocol是用来跨域的. <? ...

  3. java多线程高并发知识总结

    1.      计算机系统 使用高速缓存来作为内存与处理器之间的缓冲,将运算需要用到的数据复制到缓存中,让计算能快速进行:当运算结束后再从缓存同步回内存之中,这样处理器就无需等待缓慢的内存读写了. 缓 ...

  4. riakKV 配置

    安装好riakKV之后, 我们需要将 riak.conf 文件中的 nodename修改为本机的 IP 地址. nodename = xx@xxx.xxx.xx.xx listener.http.in ...

  5. python 网络编程(Socket)

    # from wsgiref.simple_server import make_server## def RunServer(environ,start_response):# start_resp ...

  6. spring为什么推荐使用构造器注入

    一.前言 ​ 项目中遇到一个问题:项目启动完成前,在A类中注入B类,并调用B类的某个方法. 那么调用B类的这个方法写在哪里呢,我选择写到构造器里,但是构造器先于Spring注入执行,那么执行构造器时, ...

  7. 无聊的js(马赛克)

    <!doctype html> <html lang="en"> <head> <meta http-equiv="Conten ...

  8. 用generator 根据oracle表生成java代码,数据库与代码字段不一致

    前两天用generator生成java代码时发现,生成的javabean和数据库里的字段对应不上,不是少几个就是有几个字段不一样,感觉很怪异,后来发现日志里边这个表转换成bean是日志打印了好几遍,所 ...

  9. Judy Beta 第二天

    Intro 我们采取的code review方式是两人一组,每个人在自己的分支上完成工作后向master分支发起pull request,小组的另一人对pr进行review后merge进入原仓库.gi ...

  10. DAY2练习-购物车

    print('欢迎访问购物车')money = int(input('为方便购物,请输入您的总资产:')) #输入金钱必须为数字类型shopping_price_list = [{"name ...