Amazon Interview Question

Complexity of this algorithm. How to improve the complexity?

Interview Answers

Anonymous

Jun 6, 2011

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

3

Anonymous

Jun 2, 2011

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

1

Anonymous

Jun 9, 2011

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