Amazon Interview Question

Writing a code : finding the pairs in an array