Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 786 |

@arpitsatnalika | 777 |

@tujhekya | 602 |

@prakharxyz | 601 |

@code_it_ | 591 |

@iamronak | 505 |

@imnm | 500 |

@pradeepkumarjad | 488 |

@satyam0460 | 481 |

@nitesha125 | 468 |

@Rahul Jadhav 1 | 466 |

Complete Leaderboard |

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 <= 10^{3}

0 <= A_{i} <= 10^{5}

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

Login to report an issue on this page.

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes
Triplet Family

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.