eolymp
bolt
Try our new interface for solving problems
Problems

Remove Duplicates from Sorted Array

published at 1/9/24, 9:26:10 am

include <bits/stdc++.h>

using namespace std; int main(){

int n,i;

cin>>n;

int a[n];

for (i=0;i<n;i++) {

cin>>a[i];

} cout<<a[0]<<" ";

for (i=1;i<n;i++) {

if(a[i]!=a[i-1])

cout<<a[i]<<" ";

}

}