Grokking 75: Top Coding Interview Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Longest Subarray of 1's After Deleting One Element (medium)
On this page

Problem Statement

Given a binary array nums, return the length of the longest non-empty subarray containing only 1's after removing 1 element from the array. Return 0 if there is no such subarray.

Examples

Example 1

  • Input: [1, 1, 0, 0, 1, 1]
  • Expected Output: 2
  • Justification: By removing the first 0, you get [1, 1, 0, 1, 1] and the longest sequence of 1s is [1, 1].

Example 2

  • Input: [1, 1, 0, 1, 1, 1]
  • Expected Output: 5
  • Justification: By removing the first 0, you get `[1, 1, 1, 1, 1]

.....

.....

.....

Like the course? Get enrolled and start learning!

On this page