Challenge: Find two pairs in an array such that a+b = c+d

If you are given an array, can you find two pairs such that their sum is equal?

Problem Statement

In this problem, you have to implement the string findPair(int* arr, int size) function, which will find two pairs [a, b] and [c, d] in an array such that :

a+b=c+da+b = c+d

You only have to find any two pairs in the array which satisfies the above condition.

Input

An array of distinct integers and their size.

Output

A string containing two pairs (a, b) and (c, d) which satisfy a + b = c + d in {a,b}{c,d}format

Sample Input

arr = {3, 4, 7, 1, 12, 9}
size = 6

Sample Output

{{4,12},{7,9}}

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.