485. Max Consecutive Ones最大连续1的个数
网址:https://leetcode.com/problems/max-consecutive-ones/
很简单的一题
class Solution {
public:
int findMaxConsecutiveOnes(vector<int>& nums) {
int ans = ;
int res = ;
for(auto i : nums)
{
res = i?res+:;
ans = max(ans,res);
}
return ans;
}
};

485. Max Consecutive Ones最大连续1的个数的更多相关文章
- 485 Max Consecutive Ones 最大连续1的个数
给定一个二进制数组, 计算其中最大连续1的个数.示例 1:输入: [1,1,0,1,1,1]输出: 3解释: 开头的两位和最后的三位都是连续1,所以最大连续1的个数是 3.注意: 输入的数组只包 ...
- [LeetCode] Max Consecutive Ones 最大连续1的个数
Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: [1, ...
- Leetcode485.Max Consecutive Ones最大连续1的个数
给定一个二进制数组, 计算其中最大连续1的个数. 示例 1: 输入: [1,1,0,1,1,1] 输出: 3 解释: 开头的两位和最后的三位都是连续1,所以最大连续1的个数是 3. 注意: 输入的数组 ...
- 485. Max Consecutive Ones - LeetCode
Question 485. Max Consecutive Ones Solution 题目大意:给一个数组,取连续1的最大长度 思路:遍历数组,连续1就加1,取最大 Java实现: public i ...
- 【leetcode】485. Max Consecutive Ones
problem 485. Max Consecutive Ones solution1: class Solution { public: int findMaxConsecutiveOnes(vec ...
- 485. Max Consecutive Ones【easy】
485. Max Consecutive Ones[easy] Given a binary array, find the maximum number of consecutive 1s in t ...
- 485. Max Consecutive Ones最长的连续1的个数
[抄题]: Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Inpu ...
- [LeetCode]485. Max Consecutive Ones 找到最大的连续的1的个数
题目描述 输入只有0和1的数组(长度为正整数,且<10000),找到最大的连续1的个数 比如[1,1,0,1,1,1],输出3 思路 遍历数组,统计当前连续个数curCount和最大连续值max ...
- 485. Max Consecutive Ones
题目 Given a binary array, find the maximum number of consecutive 1s in this array. Example 1: Input: ...
随机推荐
- Redis,Memcache比较
简单比较: Redis不仅仅支持简单的k/v类型的数据,同时还提供list,set,hash等数据结构的存储.memcache只支持简单的K/V类型数据, 不过memcache可以缓存其他东西如图片, ...
- 【BZOJ】4011: [HNOI2015]落忆枫音
题目链接:http://blog.csdn.net/popoqqq/article/details/45194103 写代码的时候也没有很清晰....具体看这里吧 #include<iostre ...
- ext4.2常用的几种弹框
以下记录了自己在做项目时,经常用到的几种ext弹框.项目中使用的ext是4.2版本的. 1. Ext.Msg.alert() 使用此种方式时,如果提示信息过长则提示信息会被覆盖掉一部分. Ext.Ms ...
- maven 打包不同环境
支持不同环境打包 1 pom添加如下配置: 1)添加指定打包id 区分各个环境 <profiles> <profile> <id>dev</id> &l ...
- 力扣(LeetCode)226. 翻转二叉树
翻转一棵二叉树. 示例: 思想 递归 java版 /** * Definition for a binary tree node. * public class TreeNode { * int va ...
- leecode第二十三题(合并K个排序链表)
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode ...
- Codefroces 958C2 - Encryption (medium)
C2 - Encryption (medium) 思路: 传统的dp: dp[i][j] 表示到第i个位置为止,分成j段的最大值 dp[i][j] = max(dp[l][j-1] + (sum[i] ...
- 第 3 章 镜像 - 015 - 调试 Dockerfile
如何 debug Dockerfile 通过 Dockerfile 构建镜像的过程 从 base 镜像运行一个容器 执行命令对容器做修改 执行类似 docker commit 的操作,生成一个新的镜像 ...
- 关于ascii码的一些内容
1.通过C#程序输出tab(制表符)内容. 1.1常用方式我们可以是 //测试输出\t到文件 File.WriteAllText("test.txt", "a\tb\tc ...
- Ubuntu 16.04下docker ce的安装(待完善)
参见:https://www.cnblogs.com/senlinyang/p/8203191.html https://blog.csdn.net/qq_34906391/article/detai ...