Make a Distinct Digit Array
Submissions: 4792   Accuracy: 32.61%   Difficulty: Basic   Marks: 1

Given an array of positive integers of size N. The task is to make a sorted array which will contain all distinct digits present in A.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains two lines, first line containing an integer N size of array, and second line containing the array elements.

Output:
For each test case, print the required array.

Constraints:
1 <= T <= 100
1 <= N <= 107
1 <= Ai <= 1016

Example:
Input:

2
3
131 11 48
4
111 222 333 446

Output:
1 3 4 8
1 2 3 4 6

Explanation:
Testcase 1:
1, 3, 4, and 8 are only distinct digits that can be extracted from the numbers of the array.

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

Author: saksham seth

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.