Sorting in descending order with duplicate removal
Swift
Medium
sorting
Task «Sorting in descending order with duplicate removal»
Given an array of integers, it is necessary to sort it in descending order, removing all duplicate elements. Implement the algorithm in Swift using sorting via `sort` or `sorted`. Input data: first the number of elements n, then n integers. Output data: a sorted array without duplicates, elements separated by spaces.
Input Format
First line: an integer n (1 ≤ n ≤ 1000). Second line: n integers separated by spaces.
Output Format
A string of integers sorted in descending order, without duplicates, separated by spaces.
Examples
Example 1
INPUT
7
3 3 1 1 2 2 2
OUTPUT
3 2 1
Example 2
INPUT
6
1 1 2 3 3 4
OUTPUT
4 3 2 1
Example 3
INPUT
1
-5
OUTPUT
-5
main.swift