time:O(logn),space:O(1)
time:O(logn),space:O(1)