O(1) extra space
update
nlogn solution
eliminate redundant computation
more tests