Problem title
Difficulty
Avg time to solve

Paths in a Maze
Easy
--
Positive Negative Pair
Easy
10 mins
Christmas Eve
Easy
15 mins
Letter Combinations of a Phone Number
Moderate
35 mins
Left Rotations of An Array
Moderate
10 mins
Connect Nodes at Same Level
Moderate
30 mins
Minimum Time To Solve The Problems
Hard
50 mins
Implement a phone directory
Hard
50 mins
Longest Bitonic Sequence
Moderate
15 mins
Find K-th smallest Element in BST
Easy
15 mins 6

# Search In Infinite Sorted 0-1 Array

Difficulty: EASY
Avg. time to solve
10 min
Success Rate
90%

Problem Statement

#### You are given an infinite array consisting of only ones and zeroes, in sorted order. You have to find the index of the first occurrence of 1.

##### Example:
``````If the array is 0 0 0 0 1 1 1 1… then, the first occurrence of 1 will be at index 4 therefore the answer here is 4.
``````
##### Note:
``````As the array size is infinite, the actual array won’t be given to you. Instead, you will be able to access the array elements by calling a method named ‘get’.

get(i) : returns the value present at index I.

Indexing is 0-based.

Instead of representing an infinite array in the input, we give the index of the first occurrence of 1 in the input itself. However, this input will be completely hidden from the user.

It is guaranteed that the answer will fit in a 64-bit integer.
``````
##### Input Format:
``````The only input line contains an integer X, the index of the first occurrence of 1. (Hidden to the user)
``````
##### Output Format:
``````Print an integer denoting the index of the first occurrence of 1.
``````

#### Note:

``````You do not need to print anything, the output has already been taken care of. Just implement the given function.
``````
##### Constraints:
``````0 <= ARR[i] <= 1

Time limit: 1sec
``````
##### Sample Input 1:
``````10
``````
##### Sample Output 1:
``````10
``````
##### Sample Input 2:
``````1
``````
##### Sample Output 2:
``````1
``````   Console