LeetCode题解:Max Consecutive Ones
来源:互联网 发布:如何提高网络延迟 编辑:程序博客网 时间:2024/06/07 06:21
Given a binary array, find the maximum number of consecutive 1s in this array.
Example 1:
Input: [1,1,0,1,1,1]Output: 3Explanation: The first two digits or the last three digits are consecutive 1s.The maximum number of consecutive 1s is 3.
思路:
无
题解:
int findMaxConsecutiveOnes(const std::vector<int>& nums) { int longest = 0; int currentCount = 0; for(auto i: nums) { if (i == 1) { ++currentCount; } else { longest = std::max(longest, currentCount); currentCount = 0; } } longest = std::max(longest, currentCount); return longest;}
0 0
- LeetCode题解:Max Consecutive Ones
- leetcode题解-485. Max Consecutive Ones
- LEETCODE--Max Consecutive Ones
- LeetCode: Max Consecutive Ones
- 【leetcode】Max Consecutive Ones
- LeetCode:Max Consecutive Ones
- LeetCode Max Consecutive Ones
- LeetCode Max Consecutive Ones
- leetCode-Max Consecutive Ones
- LeetCode485.Max Consecutive Ones题解
- LeetCode 485. Max Consecutive Ones
- 【Leetcode】485. Max Consecutive Ones
- LeetCode 485. Max Consecutive Ones
- [LeetCode]485 Max Consecutive Ones
- [leetcode-485]Max Consecutive Ones
- [Leetcode 485 ]Max Consecutive Ones
- Leetcode 485 Max Consecutive Ones
- LeetCode - 485. Max Consecutive Ones
- CVM ubuntux641604 搭建L2TP VPN
- HDU 1061 Rightmost Digit (求n^n的最低位)
- 利用NodeMcu和matplotlib的温度远程实时测量显示方案
- Android 小问题锦集
- java中路径问题详解
- LeetCode题解:Max Consecutive Ones
- Docker - Ubuntu 16.04安装Docker
- 小程聊微服务--微服务思想
- startActivityForResult启动Activity
- 【VS开发】Wix 安装教程
- 十进制数(字符串)转换为十六进制数
- MAC 中搭建 Apache 下的 HTTPS 服务
- MySQL索引背后的数据结构及算法原理
- vs2010 引用动态库方法