国产探花免费观看_亚洲丰满少妇自慰呻吟_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; }};
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 兴国县| 万载县| 遵义市| 广宁县| 稷山县| 丰都县| 依安县| 浪卡子县| 手机| 高阳县| 靖远县| 肇庆市| 靖江市| 永新县| 黄浦区| 新蔡县| 济阳县| 花莲市| 克拉玛依市| 奉节县| 阜新市| 炎陵县| 和硕县| 隆德县| 来安县| 吉隆县| 休宁县| 临泉县| 穆棱市| 仙游县| 潢川县| 江门市| 监利县| 和静县| 济源市| 宜川县| 舒兰市| 岳阳市| 民权县| 谢通门县| 翁牛特旗|