Objective: Given an array of integer which 1’s followed by 0’s. Find the starting index of 0.

Example:

int [] a = {1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0};
First Index from where 0 starts: 10
int [] a = {1,1,1}; //No 0 is present
output: Array does not have 0
int [] a = {0,0,0}; //Only 0’s. return the first index
output: 0

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.
__________________________________________________

Line 4 and 5 are not required
If (start > end) return 0;

Forgot to handle the base case where there are only 2 elements
//If there are only two elements
if (end == start + 1) {
if (array[start] == 0) {
return start;
} else if (array[end] == 0) {
return end;
} else {
return -1;
}
}

Also forgot to handle the empty array

if (array == null || array.length == 0)
return -1;