. You are given a file which contains a very bit sequence of 0 and 1 and it is sorted. Hence all the zeros are in front of the ones.One needs to find the first orrcurance of of 1 in the file(return the position).
The only method to access the file is through a method whose signature is — int getBitAtPosition(int position) — which returns the bit at the specified position in the file.
I thought of using a binary search till the 1 is not found …once it was found we can keep on decreasing the position linearly and saving the previous value so that if the bit at pos-- is 0 then we can get the position as pos