• + 1 comment

    Your solution is good, works in many languages, but int Java 7 it times out for some test cases, so in that language a faster solution is needed. Seems to me that the timeout period may have been too short because your solution is O(log(n)).