Tap here to switch tabs
Problem
Ask
Submissions

Problem: Longest Subarray of 1's After Deleting One Element

med
30 min
Explore how to apply the sliding window technique to find the longest subarray of 1s after deleting one element from a binary array. This lesson helps you understand problem constraints, develop an efficient approach, and implement a solution that meets coding interview standards.

Statement

Given a binary array nums, remove exactly one element from it. Return the length of the longest non-empty subarray consisting entirely of 11's in the resulting array. If no such subarray exists, return 00.

Note: Exactly one element must always be deleted, even if all elements are 11's.

Constraints:

  • 11 \leq nums.length 105\leq 10^5

  • nums[i] is either 00 or 11

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Longest Subarray of 1's After Deleting One Element

med
30 min
Explore how to apply the sliding window technique to find the longest subarray of 1s after deleting one element from a binary array. This lesson helps you understand problem constraints, develop an efficient approach, and implement a solution that meets coding interview standards.

Statement

Given a binary array nums, remove exactly one element from it. Return the length of the longest non-empty subarray consisting entirely of 11's in the resulting array. If no such subarray exists, return 00.

Note: Exactly one element must always be deleted, even if all elements are 11's.

Constraints:

  • 11 \leq nums.length 105\leq 10^5

  • nums[i] is either 00 or 11