Skip to content

Commit 3c7c072

Browse files
committed
Added README.md file for Longest Subarray of 1's After Deleting One Element
1 parent 36297f1 commit 3c7c072

File tree

1 file changed

+36
-0
lines changed
  • 1586-longest-subarray-of-1s-after-deleting-one-element

1 file changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<h2><a href="https://leetcode.com/problems/longest-subarray-of-1s-after-deleting-one-element">Longest Subarray of 1's After Deleting One Element</a></h2> <img src='https://img.shields.io/badge/Difficulty-Medium-orange' alt='Difficulty: Medium' /><hr><p>Given a binary array <code>nums</code>, you should delete one element from it.</p>
2+
3+
<p>Return <em>the size of the longest non-empty subarray containing only </em><code>1</code><em>&#39;s in the resulting array</em>. Return <code>0</code> if there is no such subarray.</p>
4+
5+
<p>&nbsp;</p>
6+
<p><strong class="example">Example 1:</strong></p>
7+
8+
<pre>
9+
<strong>Input:</strong> nums = [1,1,0,1]
10+
<strong>Output:</strong> 3
11+
<strong>Explanation:</strong> After deleting the number in position 2, [1,1,1] contains 3 numbers with value of 1&#39;s.
12+
</pre>
13+
14+
<p><strong class="example">Example 2:</strong></p>
15+
16+
<pre>
17+
<strong>Input:</strong> nums = [0,1,1,1,0,1,1,0,1]
18+
<strong>Output:</strong> 5
19+
<strong>Explanation:</strong> After deleting the number in position 4, [0,1,1,1,1,1,0,1] longest subarray with value of 1&#39;s is [1,1,1,1,1].
20+
</pre>
21+
22+
<p><strong class="example">Example 3:</strong></p>
23+
24+
<pre>
25+
<strong>Input:</strong> nums = [1,1,1]
26+
<strong>Output:</strong> 2
27+
<strong>Explanation:</strong> You must delete one element.
28+
</pre>
29+
30+
<p>&nbsp;</p>
31+
<p><strong>Constraints:</strong></p>
32+
33+
<ul>
34+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
35+
<li><code>nums[i]</code> is either <code>0</code> or <code>1</code>.</li>
36+
</ul>

0 commit comments

Comments
 (0)