Count the total number of distinct pairs that can be formed from all contiguous sub-arrays consisting of distinct elements of an array A[ ] of size 'N'.
Input
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 two space separated integers N, where N is the size of array.
The second line of each test case contains N space separated integers denoting elements of the array A[ ].
Output:
Print out the the number of pairs that can be formed with the elements of the corresponding sub-arrays.
Constraints:
1 <= T <= 100
1 <= N <= 30
0<= A[i] <= 10
Example :
Input:
3
3
3 3 4
6
1 4 2 4 3 2
4
1 2 2 3
Output:
1
8
2
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 | 175 |
manvirag982 | 158 |
Core_Ka_Bachha | 137 |
yash_sharan | 136 |
rajupraaa1234 | 133 |
mr_kksparrow | 433 |
manvirag982 | 374 |
rajupraaa1234 | 268 |
Exception_404 | 254 |
PranathiBhuvanagiri | 242 |
blackshadows | 5331 |
Ibrahim Nash | 5219 |
akhayrutdinov | 5111 |
mb1973 | 4929 |
Quandray | 4567 |