Solutionf for pairs problem from livestreet (hackerrank).