Qualcomm Interview Question
Software Engineer / DevelopersI think the above suggested solution would take no less average time then applying the binary search algorithm . So we have a easy solution for this doing this in 'log n' time . Do u need it further faster than this, even I would like to know if there is any way to improve time complexity .
We can start inquiring the the numbers at indices at 2, 4, 8, ... till we find a 1 at say 2^(n-1) and a 0 at 2^n. Now we can do binary search between these two indices for 0.
- Anonymous May 22, 2007