Longest Subarray of 1's After Deleting One Element
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given a binary array nums. You **must** delete exactly one element from it.
After the deletion, return the length of the longest non-empty contiguous subarray made up only of 1s. If no such subarray exists, return 0.
Note that the deletion is mandatory: an array of all 1s loses one element. Aim for O(n).
Examples
Constraints
- 1 <= nums.length <= 10^5
- nums[i] is 0 or 1
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.