You are given a binary array nums (it has only 0s and 1s). You must delete exactly one element.
After the deletion, look for the longest block of 1s that sit next to each other. Return its length. If there is no 1 left, return 0.
Examples
Example 1:
Input: nums = [1,0,1,1,0,1,1,1]
Output: 5
Explanation: Delete the 0 at position 4 (counting from 0). The array becomes [1,0,1,1,1,1,1], and the last five numbers are all 1s.
Example 2:
Input: nums = [1,1,1,1]
Output: 3
Explanation: There is no 0, but you must still delete one number. Delete a 1. Three 1s are left in a row.
Example 3:
Input: nums = [0,0]
Output: 0
Explanation: After deleting one number, the array is [0]. It has no 1.