Sub-Array Pairs
Submissions: 148   Accuracy:

44.58%

  Difficulty: Easy   Marks: 2

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

 

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

Author: Rohan Malhotra


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.