Dsa
Sorting
Warm-up
Sort With Duplicates
Design a program that sorts a list of integers where duplicates are allowed. The program should read from standard input and print the sorted list. It should also ensure that the output contains unique entries only, i.e., each number should appear once in the output.
Input format:
- The first line contains an integer n (1 ≤ n ≤ 100). The second line contains n integers separated by spaces.
Output format:
- A single line containing the unique sorted integers separated by spaces.
Example:
Input:
6
3 1 4 1 5 9
Output:
1 3 4 5 9
Key concepts
sortingduplicatesarray
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now