Given an array of integers. Check whether it contains a triplet that sums up to zero.
The first line of input contains an integer T, denoting the number of test cases. Then T test cases follow. The first line of each test case contains an integer N, denoting the number of elements in array. The second line of each test case contains N space separated values of the array.
For each test case, output will be 1 if triplet exists else 0.
You don't need to read input or print anything. Your task is to complete the boolean function findTriplets() which takes the array arr and the size of the array (n) as inputs and returns True if the given array has a triplet with zero sum and False otherwise.
Expected Auxiliary Space: O(1)
Expected Time Complexity: O(n2)
1 <= T <= 100
1 <= N <= 104
-106 <= Ai <= 106
0 -1 2 -3 1
1 2 3
Testcase 1: 0, -1 and 1 forms a triplet with sum equal to 0.
Testcase 2: No triplet exists which sum to 0.
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.