1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/最大连续 1 的个数 [max-consecutive-ones].html
2022-03-29 12:43:11 +08:00

28 lines
691 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给定一个二进制数组 <code>nums</code> 计算其中最大连续 <code>1</code> 的个数。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>nums = [1,1,0,1,1,1]
<strong>输出:</strong>3
<strong>解释:</strong>开头的两位和最后的三位都是连续 1 ,所以最大连续 1 的个数是 3.
</pre>
<p><strong>示例 2:</strong></p>
<pre>
<b>输入:</b>nums = [1,0,1,1,0,1]
<b>输出:</b>2
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
<li><code>nums[i]</code>&nbsp;不是&nbsp;<code>0</code>&nbsp;就是&nbsp;<code>1</code>.</li>
</ul>