leetcode485
public class Solution {
public int FindMaxConsecutiveOnes(int[] nums) {
int Consecutive = ;
int max = ;
for (int i = ; i < nums.Length; i++)
{
if (nums[i] == )
{
Consecutive++;
if (i == nums.Length - )
{
if (Consecutive > max)
{
max = Consecutive;
}
}
}
else
{
if (Consecutive > max)
{
max = Consecutive;
}
Consecutive = ;
}
}
//Console.WriteLine(max.ToString());
return max;
}
}
https://leetcode.com/problems/max-consecutive-ones/#/description
leetcode485的更多相关文章
- [Swift]LeetCode485. 最大连续1的个数 | Max Consecutive Ones
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. 注意: 输入的数组 ...
- leetcode485——最大连续1的个数(easy)
一.题目描述 给定一个二进制数组, 计算其中最大连续1的个数. 示例 1: 输入: [1,1,0,1,1,1] 输出: 3 解释: 开头的两位和最后的三位都是连续1,所以最大连续1的个数是 3. 注意 ...
- LeetCode485 最大连续1的个数
给定一个二进制数组, 计算其中最大连续1的个数. 示例 1: 输入: [1,1,0,1,1,1] 输出: 3 解释: 开头的两位和最后的三位都是连续1,所以最大连续1的个数是 3. 注意: 输入的数组 ...
- 2017-3-4 leetcode 414 485 495
虽说周末要早起来着,但是日子过得有点奇怪,一不小心就忘掉了... leetcode414 https://leetcode.com/problems/third-maximum-number/?tab ...
随机推荐
- hello1与hello2在glassfish上部署
部署hello1 打开项目实例 找到hello1(tutorial-examples-master\web\jsf\hello1) 并在当前目录打开cmd并输入mvn install命令在hello1 ...
- Maven Dependency错误——下载失败问题解决方案
问题描述: The container 'Maven Dependencies' references non existing library '${groupid}/${artifactid}-$ ...
- yocto和bitbake
一.yocto 1.yocto简介 Yocto 是一个开源社区通过它提供模版.工具和方法帮助开发者创建基于linux内核的定制系统,支持ARM, PPC, MIPS, x86 (32 & 64 ...
- 读写XML文档时,去掉新增加节点的“空命名空间”(xmlns=””)
在做对ReprotViewer编程时,想做一个用户可以更改显示/打印列的功能,大致看了下,只需要通过对rdlc文件中改变其<Hidden>节点值为false/true,即可实现对应某列的显 ...
- GOOGLE高级搜索的秘籍
一.摘要 本文内容来源自互联网,全面的介绍Google搜索的各种功能和技巧. 二.GOOGLE简介 Google(http://www.google.com/)是一个搜索引擎,由两个斯坦福大学博士生L ...
- maven 知识点2
maven 命令: table th:first-of-type { width: 500px; } table th:nth-of-type(2) { } 命令 含义 mvn help:effect ...
- 如何使用button在tab中新建打开一个链接页
在APPBOX某页中如何使用button按钮打开一个新的链接页.比如说百度.谷歌等 在后台的单击事件中使用以下语句即 string url = "DownloadIma ...
- java中String对象的存储位置
public class Test { public static void main(String args[]) { String s1 = "Java"; String s2 ...
- JZ2440 裸机驱动 第11章 通用异步收发器UART
本章目标: 了解UART原理: 掌握S3C2410/S3C2440中UART的使用 11.1 UART原理及UART内部使用方法 11.1.1 UART原理说明 UART用于传输串行数据: ...
- gcc gdb调试 & 命令行带参 (一) ******
用GDB调试程序 GDB概述———— GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具.或许,各位比较喜欢那种图形界面方式的,像VC.BCB等IDE的调试,但如果你是在UNIX平台下做软 ...