Index of First 1 in a Binary Sorted Infinite Array
Medium

Problem Statement

Given an infinite sorted binary array (containing only 0s and 1s), find the index of the first occurrence of 1.

Examples

1Example 1
Input:
{ "arr": [ 0, 0, 0, 0, 0, 1, 1, 1, 1 ] }
Output:
5
2Example 2
Input:
{ "arr": [ 1, 1, 1, 1, 1, 1 ] }
Output:
0
3Example 3
Input:
{ "arr": [ 0, 0, 0, 0, 0, 0 ] }
Output:
-1
Loading...

Sign in to Run Code and Submit