
Two enemies are distinct if their strengths are different.
The first line contains an integer 'T' which denotes the number of test cases or queries to be run.
The first line of each test case contains a single integer ‘N’ denoting the size of the ‘ARR’ array.
The next line contains ‘N’ space-separated integers denoting the values of elements of the ‘ARR’ array.
For each test case, print a single line containing the distinct elements in an array.
The output of each test case will be printed in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 5
1 <= N <= 5000
0 <= ARR[i] < 10 ^ 6
Where ‘ARR[i]’ represents the elements of the array.
Time Limit: 1 sec
The idea here is to use the brute force approach and for each element, we check for all the previous elements if we find the same element we break from the loop, and if after one loop both ‘i’ and ‘j’ becomes equal we increase the ‘ans’ as we can say a different element is present.
The idea here is to sort the array then we can simply traverse the array and check if the next element is different from the current element we can increase the ‘ans’ .
The idea here is to use the hash set as it maintains a unique entry for each element and whenever we encounter any element we first check in our hash set if it is already present we continue else we push it into our hash set and increase the ‘ans’.