Given an array, the task is to find maximum triplet sum in the array.
Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains an Integer N denoting size of array and the second line contains N space separated elements.
Output:
For each test case, print the maximum triplet sum in new line.
Constraints:
1<=T<=100
3<=N<=106
-105<=A[i]<=105
Example:
Input:
2
6
1 0 8 6 4 2
7
1 2 3 0 -1 8 10
Output:
18
21
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.
bruceewayne | 119 |
rajupraaa1234 | 110 |
SUZAKU | 104 |
yash_sharan | 104 |
Core_Ka_Bachha | 99 |
mr_kksparrow | 433 |
manvirag982 | 302 |
rajupraaa1234 | 245 |
Exception_404 | 244 |
snow_den_ | 236 |
blackshadows | 5331 |
Ibrahim Nash | 5219 |
akhayrutdinov | 5111 |
mb1973 | 4929 |
Quandray | 4567 |