add a O(n) solution, TLE
bug fixed, but still TLE
add a recirsive solution O(logn), accepted
add a non-recursive O(logn) solution