O(logn),Be careful of dealing with edge cases, overflow. AC