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