Pairs linear solution using Hash
Naive solution