Given a binary array
nums
, you should delete one element from it.
Return the size of the longest non-empty subarray containing only1
's in the resulting array. Return0
if there is no such subarray.
Constraints:
1 <= nums.length <= 10^5
nums[i]
is either0
or1
.
給一個二元陣列
nums
,你必須刪除裡面其中一個元素。
回傳最長只包含1
的非空子陣列。回傳0
如果不存在這種子陣列。
限制:
1 <= nums.length <= 10^5
nums[i]
只會是0
或是1
。
1
連續出現的次數0
代表間隔,將 1
的計數重置[0,1,1,1,0,1,1,0,1]
改為 [0, 3, 2, 1]
0
,也要將目前計數記下來0
,要回傳 0
1
,要回傳數量減一(一樣得刪除一個)LeetCode
C++