Skip to main content

Practice · 1 of 5

Distinct, in Order

CHALLENGE
Difficulty: beginner+25 XP

**Description:** Read n integers. Print the distinct values in ascending order, space-separated, then print the count of distinct values on the next line. **Input:** Line 1: n (1 <= n <= 2*10^5). Line 2: n integers (|a_i| <= 10^9). **Output:** Line 1: distinct values ascending. Line 2: their count. **Example:** 6 / 4 2 4 7 2 9 -> 2 4 7 9 / 4.

Back to lesson: Practice: STL Problem Set