Remove Duplicates from a Sorted Array
Easyjavapythonccppjavascript
Given a sorted array of N integers, remove duplicate values so that every distinct value appears only once, keeping the sorted order.
Input Format
The first line contains an integer N. The second line contains N space-separated integers in non-decreasing order.
Output Format
Print the distinct values in increasing order, separated by single spaces, on one line.
Example 1
Input
7 1 1 2 2 3 4 4
Output
1 2 3 4
Explanation: Repeated copies are removed; each value is kept once.
- 1 <= N <= 100000
- -1000000000 <= A[i] <= 1000000000
- The array is sorted in non-decreasing order.