Compact a Sorted Array
The array is sorted. Print it with consecutive duplicates removed.
Input: the first line has N; the second line has N sorted integers.
Output: the distinct values in order.
Constraints:
- 1 ≤ N ≤ 105
- −109 ≤ ai ≤ 109
Sample Tests
Input 1
6 1 1 2 3 3 3
Output 1
1 2 3
Input 2
1 5
Output 2
5
Discussion (opens after you solve — no spoilers before)
No comments yet.