Amazon interview question

Writing a code : finding the pairs in an array