国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

485. Max Consecutive Ones

2019-11-08 02:57:44
字體:
來源:轉載
供稿:網友

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.

Input: [1,1,0,1,1,1] Output: 3 Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3.

class Solution {public: int findMaxConsecutiveOnes(vector<int>& nums) { int nTimes = 0, maxOne = 0; int sz = nums.size(); for(int i = 0; i < sz; ++i){ if(nums[i] == 1){ ++nTimes; if(nTimes > maxOne) maxOne = nTimes; } else nTimes = 0; } return maxOne; }};
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 玛曲县| 西贡区| 福清市| 安国市| 大洼县| 曲沃县| 隆子县| 金乡县| 兴和县| 云南省| 绥芬河市| 商丘市| 英吉沙县| 镇远县| 财经| 邵阳县| 栾川县| 阳谷县| 呼玛县| 克拉玛依市| 兰考县| 马尔康县| 彩票| 金平| 宁德市| 正宁县| 天镇县| 潢川县| 开远市| 岫岩| 双鸭山市| 三门县| 龙岩市| 喀喇| 阳谷县| 新巴尔虎右旗| 积石山| 富蕴县| 汪清县| 南郑县| 吕梁市|