Longest Subarray of 1's After Deleting One Element

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.

Constraints

  • 1 <= nums.length <= 10^5
  • nums[i] is either 0 or 1.
Saving… · 2 lines
class Solution:
def longestSubarrayOfOnesAfterDeletingOneElement(self, nums: List[int]) -> int:
Console

Click Run to execute sample tests.