Longest Subarray of 1's After Deleting One Element
Given a binary array `nums`, you must delete exactly one element from it. Return the size of the longest non-empty subarray containing only 1s in the resulting array. Return 0 if there is no such subarray.
30:00
Longest Subarray of 1's After Deleting One Element
Given a binary array nums, you must delete exactly one element from it. Return the size of the longest non-empty subarray containing only 1s in the resulting array. Return 0 if there is no such subarray.
Example 1:
Input: {"nums":[1,1,0,1]}
Output: 3
Constraints:
1≤nums.length≤105
nums[i] is either 0 or 1
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"nums":[1,1,0,1]}
Slide a window over 4 cells that may hold at most one zero; that zero is the element we delete.