250. Remove Duplicates
You are given n integers in non-decreasing order. Print each distinct
value once, keeping the order.
Because the input is sorted, every group of equal values sits together. So a value is a duplicate exactly when it equals the one immediately before it, and you never need to look further back than one position.
That is the whole problem, and it is why sorting first is such a common opening move: it turns "have I seen this before" into "is this the same as the last one".
Constraints - `1 ≤ n ≤ 200000` - `-1000000000 ≤ a[i] ≤ 1000000000`
Input
The first line contains an integer n.
The second line contains n integers in non-decreasing order.
Output
Print the distinct values in order, separated by single spaces.