AC 2
-using binary search (iteratively)