Amazon interview question

Complexity of this algorithm. How to improve the complexity?

Interview Answers

Anonymous

6 June 2011

or could be linear time if you're allowed to use a hash table

3

Anonymous

2 June 2011

N^2 and can be improved to n logn using binary serach.

1

Anonymous

9 June 2011

I'm pretty sure hash table is the answer they were looking for...