BETA

Submissions: 248 Accuracy: 35.08%

Triplet Family (Function Problem)

Given an array of integers arr[], you task is to complete the function findTriplet(), that should 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:
The function takes two arguments as input, an array of integers arr[] and an integer element N, denoting the size of the array.
There will be T test cases, for each test case the function will be called separately.

Output:
For each test case the function should return, any triplet found from the array in a container result, if no such triplet is found return the container result as empty.

Constraints:
1<=T<=100
1<=N<=103
0<=A[]<=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:

Test Case 1:
Triplet Formed: {2, 19, 21}
Hence 1

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

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

Note:The Input/Ouput format and Example given are used for system's internal purpose, and should be used by a user for Expected Output only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

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

Contributor: Harshit Sidhwa

It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result: