Triplet Family
Submissions: 3559   Accuracy:

37.95%

  Difficulty: Basic   Marks: 1

Given an array A of integers. Find three numbers such that sum of two elements equals the third element and return the triplet in a container result, if no such triplet is found return the container as empty.

Input:
First line of input contains number of testcases. For each testcases there will two lines. First line contains size of array and next line contains array elements.

Output:
For each test case output the triplets, if any triplet found from the array, if no such triplet is found, output -1.

Your Task: Your task is to complete the function to find triplet and return container containing result.

Constraints:
1 <= T <= 100
1 <= N <= 103
0 <= Ai <= 105

Example:
Input:

3
5
1 2 3 4 5
3
3 3 3
6
8 10 16 6 15 25

Output:
1
-1
1

Explanation:
Testcase 1:
Triplet Formed: {2, 1, 3}
Hence 1 

Test Case 2:
Triplet Formed: {}
Hence -1

Test Case 3:
Triplet Formed: {10, 15, 25}
Hence 1

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

Contributor: Harshit Sidhwa
Author: harshitsidhwa


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.