For the Question:
Given an infinite sorted array (or an array with unknown size), find if a given number ‘key’ is present in the array. Write a function to return the index of the ‘key’ if it is present in the array, otherwise return -1.
My approach was the following -
start = Integer.MAX_VALUE
for (reader.get(start) == Integer.MAX_Value) {
start = start/2
}
My thinking was that we can reach close to the mid of the array using this approachafter which t this point I can make a decision on which half the key would lie (if it exists)