Given an array containing only zeros and ones, find the index of the zero that, if converted to one, will make the longest sequence of ones.
For instance, given the array:
```
[1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 1]
```
replacing the zero at index 10 (counting from 0) forms a sequence of 9 ones:
```
[1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1]
                  '------------^------------'
```
Your task is to complete the function that determines where to replace a zero with a one to make the maximum length subsequence.
**Notes:**
- If there are multiple results, return the last one:
 `[1, 1, 0, 1, 1, 0, 1, 1] ==> 5`
- The array will always contain only zeros and ones.
Can you do this in one pass?
def replace_zero(arr):
    # (len, index)
    best_len, best_idx = 0, 0
    curr_len, curr_idx = 0, None

    for i, e in enumerate(arr):
        if e == 1:
            curr_len += 1
        else:
            if curr_len >= best_len:
                best_len, best_idx = curr_len, curr_idx

            if curr_idx is None:
                curr_len += 1
            elif i - curr_idx < 2:
                curr_len = 1
            else:
                curr_len = i - curr_idx
            curr_idx = i

    if curr_len >= best_len:
        best_len, best_idx = curr_len, curr_idx

    return best_idx
def replace_zero(arr):
    # (len, index)
    best_len, best_idx = 0, 0
    curr_len, curr_idx = 0, None

    for i, e in enumerate(arr):
        if e == 1:
            curr_len += 1
        else:
            if curr_len >= best_len:
                best_len, best_idx = curr_len, curr_idx

            if curr_idx is None:
                curr_len += 1
            elif i - curr_idx < 2:
                curr_len = 1
            else:
                curr_len = i - curr_idx
            curr_idx = i

    if curr_len >= best_len:
        best_len, best_idx = curr_len, curr_idx

    return best_idx