Number of Groups
Submissions: 3412   Accuracy:

49.6%

  Difficulty: Easy   Marks: 2

Given an array Arr[] of N distinct integers. Write a program to find the count of groups of 2 or 3 integers that can be formed by choosing integers from the given array such that sum of integers in each of the group is divisible by three.

Input:
First line of input contains a single integer T which denotes the number of test case. Then T test case follows. First line of each test case contains a single integer N which denotes number of elements in the array. Second line of each test case contains N space separated integers.

Output:
For each test case, print the count of all the groups of 2 or 3 integers formed from the given array such that sum of elements in the group is divisible by 3.

Constraints:
1<=T<=100
1<=N<=105
1<=Arr[i]<=105

Example:
Input:

2
6
1 5 7 2 9 14
4
3 6 9 12
Output:
13
10

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

Contributor: Harsh Agarwal
Author: harsh.agarwal0


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.