485. Max Consecutive Ones
来源:互联网 发布:js 读取ios沙盒文件 编辑:程序博客网 时间:2024/06/07 02:26
https://leetcode.com/problems/max-consecutive-ones
分析
也就是找一个二进制数组中最大的连续1的个数,简单点就遍历统计就可以了。
int findMaxConsecutiveOnes(int* nums, int numsSize) { int i = 0; int maxLen = 0; int tmpLen = 0; for (i = 0; i < numsSize; i++) { if (nums[i] == 1) { tmpLen++; if (tmpLen > maxLen) { maxLen = tmpLen; } } else { tmpLen = 0; } } return maxLen;}
0 0
- 485. Max Consecutive Ones*
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485. Max Consecutive Ones
- 485.Max Consecutive Ones
- Leetcode Binary Watch
- CentOS_6.7脚本静默安装MySQL5.6
- Vi语法总结
- JQueryEasyUI 组件 datagrid组件(数据表格组件)
- 数据结构 — 查找I
- 485. Max Consecutive Ones
- SPOJ 纽约大学ACM第一题TEST
- Android应用主界面Tab切换框架详解之Fragment
- 数据结构 — 查找II
- 数据结构 — 查找II
- [问题笔记]串口只能显示不能输入
- C++ 建立本地网络服务器 (Boost.Asio库)
- 欢迎使用CSDN-markdown编辑器
- 520. Detect Capital