problem

485. Max Consecutive Ones

solution1:

  1. class Solution {
  2. public:
  3. int findMaxConsecutiveOnes(vector<int>& nums) {
  4. if(nums.empty()) return ;
  5. int ans = , max = INT_MIN;
  6. for(int i=; i<nums.size(); i++)
  7. {
  8. if(nums[i]==) ans++;
  9. else if(nums[i]!=)
  10. {
  11. if(max<ans) max = ans;
  12. ans = ;
  13. }
  14. }
  15. return max>ans ? max : ans;
  16. }
  17. };

参考

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. ReactJS之遍历对象的方法

    const obj = { channel: “wevmvmklskdosll12k;0”, index:0 }; Object.keys(obj).map(key => console.log ...

  2. 2015-112 ado.net2

    CRUD:create read update delete 七. 数据绑定数据列的转换 在gridview中添加<OnRowDataBound="GridView1_RowDataB ...

  3. jq、js判断元素是否在可视区域内

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style> ...

  4. PDF 补丁丁 0.6.0.3288 版发布(修复“合并文件”功能的文件夹文件排序问题)

    新的测试版修复了合并文件功能中添加名称带有“.”点号的文件夹时无法正常排序文件的问题. 使用合并文件功能的用户建议更新.

  5. 【性能测试】LoadRunner11安装(包含破解、汉化)

    LoadRunner安装(包含破解.汉化) 安装LoadRunner a.以解压包的方式打开[性能测试工具LR11.00].loadrunner-11.iso文件,运行“setup.ext”(花费时间 ...

  6. MYSQL查询操作 详细

    学习目标 1 掌握select查询所有字段.指定字段的数据 2 掌握消除重复行命令distinct 3 掌握as给字段.表起别名 4 掌握条件查询where后跟比较运算符.逻辑运算符的用法 5 掌握条 ...

  7. Spring MVC扩展

    使用@ResonseBody实现异步请求时返回的数据对象的输出. 通过配置StringHttpMessageConverter消息转换器来解决JSON数据传递中出现的中文乱码问题. 在实际项目开发中, ...

  8. iSlide——智能图表的用法

    iSlide中有一个“智能图表”功能,用于制作漂亮.明了的图表.单击“智能图表”,会弹出一个对话框.从中,可以选择权限.分类和数量级,也可以直接搜索. 实战: 我想做一个全班不同年级近视人数的统计报, ...

  9. [Leetcode 72]编辑距离 Edit Distance

    [题目] Given two words word1 and word2, find the minimum number of operations required to convert word ...

  10. 自己设置 WiFi

    不想安装免费WiFi? 简单,一行命令搞定 首先,打开你的 cmd 面板, 然后敲出命令: netsh wlan set hostednetwork mode=allow ssid=wifi key= ...