Distinct absolute array elements
Submissions: 1446   Accuracy:

48.81%

  Difficulty: Easy   Marks: 2

Count the number of distinct absolute values from a sorted array containing N integers. An absolute value of a number is | a |  ( positive ) value of it.
 

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 an integer N, where N is the size of the array A[ ].
The second line of each test case contains N space separated sorted integers, denoting elements of the array
A[ ].

Note: The array can contain duplicate values.
 

Output:
For each test case output a single line containing the no of distinct absolute values present in the array .
Remember to output the answer of each test case in a new line.

 

Constraints:
1 <= T <= 100
1 <= N <= 30
-10^9<= A[i] <= 3*10^9

 

Examples :

Input:
3
4
-35 73 73 73 
9
-44 -31 -6 6 46 52 52 55 93
6
-3 -2 0 3 4 5


Output:
2
7
5


Expected Time Complexity:
O(n)


 

** 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.