Longest Run of Ones After One Required Deletion
Company: Amazon
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Other
### Problem
Delete exactly one element of the binary array nums. Return the longest all-one contiguous subarray length in the resulting array,or 0 if there is no nonempty all-one subarray.
```cpp
class Solution {
public:
int longestSubarray(vector<int>& nums);
};
```
### Examples
**Example 1:**
```text
Input: nums = [1,0,1,1]
Output: 3
Explanation: Delete the zero to join all three ones.
```
**Example 2:**
```text
Input: nums = [1,1]
Output: 1
Explanation: One element must be deleted even though there is no zero.
```
### Constraints
- nums has length 1 to 100000.
- Each entry is 0 or 1.
### Contract considerations
The deletion is mandatory and is not a bit flip.
```hint Read the boundary condition
The deletion is mandatory. Check all-one input, all-zero input, and a single-entry array.
```
### Boundary reminders
The deletion is mandatory and is not a bit flip.
Overview: Longest Run of Ones After One Required Deletion. Delete exactly one element of the binary array nums.