add O(n^2) impl.
add O(n) impl.
fix bug of ouput the same index twice.