Bloomberg Interview Question

Find an object in a sorted array in O(logn) time.

Interview Answer

Anonymous

Sep 3, 2014

Binary search is the obvious answer (although its implementation is surprisingly tricky). But in C++ pretty easy: #include std::binary_search(arr.begin(), arr.end(), value);