Leetcode#1493. Longest Subarray of 1's After Deleting One Element
Problem
Given a binary array nums
, you should delete one element from it.
Return the size of the longest non-empty subarray containing only 1
‘s in the resulting array. Return 0
if there is no such subarray.
Example 1:
1 | Input: nums = [1,1,0,1] |
Example 2:
1 | Input: nums = [0,1,1,1,0,1,1,0,1] |
Example 3:
1 | Input: nums = [1,1,1] |
Constraints:
1 <= nums.length <= 10^5
nums[i]
is either0
or1
.
Solve
直接用**1004. Max Consecutive Ones III 作法去改**
1 | class Solution: |
本部落格所有文章除特別聲明外,均採用 CC BY-NC-SA 4.0 許可協議。轉載請註明來自 Imisky!
評論