#K81547. Remove Duplicates and Sort
Remove Duplicates and Sort
Remove Duplicates and Sort
You are given an array of integers. Your task is to remove all duplicate numbers and then sort the resulting unique integers in non-decreasing order.
Input Format:
The first line contains an integer \(n\) (\(n \ge 0\)), representing the number of integers in the array. The second line contains \(n\) integers separated by spaces.
Output Format:
Output a single line containing the unique integers sorted in non-decreasing order, separated by a single space. If the array is empty, output nothing.
Example:
For input:
5
4 6 4 3 6
The output should be:
3 4 6
The solution must handle large inputs efficiently. The algorithm should ideally run in \(O(n \log n)\) time complexity, where \(n\) is the number of elements in the input array.
inputFormat
The input begins with a single integer \(n\) (\(n \ge 0\)) on the first line. The second line contains \(n\) integers separated by spaces representing the elements of the array.
outputFormat
Print the sorted list of unique integers in one line, separated by a space. If the array is empty, output nothing.
## sample5
4 6 4 3 6
3 4 6