# Maximum Number Of Distinct Elements Solution codechef

Table of Contents

# Maximum Number Of Distinct Elements Solution codechef

Given an array  of length , find an array  of length  where  such that array  where  has maximum number of distinct integers.

In case of multiple answers, print any.

### Input Format Maximum Number Of Distinct Elements Solution codechef

• First-line will contain , the number of test cases. Then the test cases follow.
• Each test case contains two lines of input.
• First-line contains a single integer .
• Second-line contains  space-separated integers .

### Output Format Maximum Number Of Distinct Elements Solution codechef

For each test case, output in a single line  space-separated integers , the elements of the array  such that array  has the maximum number of distinct elements.

If the output array doesn’t follow the constraints or the number of distinct elements in the array  is less than the optimal value, you will receive a wrong answer verdict.

### Constraints Maximum Number Of Distinct Elements Solution codechef

• Sum of  over all tests is atmost .

### Sample Input 1 Maximum Number Of Distinct Elements Solution codechef

3
3
2 1 3
2
1 1
6
1 2 3 3 2 1


### Sample Output 1 Maximum Number Of Distinct Elements Solution codechef

3 1 2
2 3
0 1 2 3 4 5


### Explanation Maximum Number Of Distinct Elements Solution codechef

Test Case : Array . So the number of unique elements are .

Test Case : Array . So the number of unique elements is .

Test Case : Array   . So the number of unique elements are .

In all the  cases, the number of unique elements can’t be increased any further for any choice of the array .