Find index of 0 to be replaced to get maximum length sequence of continuous ones

Given a binary array, find the index of 0 to be replaced with 1 to get the maximum length sequence of continuous 1s. Return that index.

Example Solution

Let array arr equal to [ 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ]. The index to be replaced is 7 to get continuous sequence of length 6 containing all 1s. Therefore the solution should return the integer 7.

Contributed by Murat Sütunç