Maximum length of consecutive ones after deleting one element (Max Consecutive Ones After Deleting One Element)
Condition:
Given a non-empty array consisting of only zeros and ones. Find the maximum length of consecutive ones that can be obtained by deleting exactly one element from the array. Deleting one element is mandatory, even if the array consists entirely of ones.
Input data:
- nums – a non-empty array of integers, each element is 0 or 1
Output:
- An integer – the maximum length of consecutive ones after deleting exactly one element
Constraints:
- 1 <= nums.length <= 10^5
- nums[i] is 0 or 1
Example:
Go code:
```go
// Available without import: sort, fmt, encoding/json
package main
func MaxOnes(nums []int) int {
// TODO: write solution here
return 0
}
```
Python code:
```python
# Available without import: json, sys, io
def max_ones(nums):
# TODO: write solution here
return 0
```