Sum equals to Sum
Submissions: 6987   Accuracy:

36.69%

  Difficulty: Easy   Marks: 2

Given an array A of distinct integers. The task is to find if there are two pairs (a, b) and (c, d) such that a+b = c+d, and elements of array are distinct.

Input:
First line consists of T test cases. First line of every test case consists of N, denoting the number of elements of array. Second line of every test case consists of elements of array.

Output:
Singple line output, print the 1 if pair exsits else 0.

Constraints:
1 <= T <= 200
1 <= N <= 105
1 <= Ai <= 106

Example:
Input:

2
7
3 4 7 1 2 9 8
7
65 30 7 90 1 9 8
Output:
1
0
Explanation:
Testcase 1:
(3, 7) and (9, 1) are the pairs whose sum are equal.

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.