Four Elements
Submissions: 31720   Accuracy:

25.46%

  Difficulty: Easy   Marks: 2

Given an array A of N integers, find a combination of four elements in the array whose sum is equal to a given value X.

Input:
First line consists of T test cases. First line of every test case consists of an integer N, denoting the number of elements in an array. Second line consists of N spaced array elements. Third line of every test case X.

Output:
Single line output, print 1 if combination is found else 0.

Constraints:
1 <= T <= 100
1 <= N <= 106

Example:
Input:

1
6
1 5 1 0 6 0
7
Output:
1

Explantion:
Testcase 1:
1, 5, 1, 0 are the four elements which makes sum 7.

** 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.