Amazon Interview Question

Write the a function that counts all pairs in an array.