Skip to content

Commit

Permalink
Using set
Browse files Browse the repository at this point in the history
  • Loading branch information
WaderManasi committed Aug 10, 2020
1 parent e5812ae commit e596241
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions Standard Template Library/Removing_Duplicate_Using_Set.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//https://practice.geeksforgeeks.org/problems/remove-duplicate-elements-from-sorted-array/1/?track=ppc-arrays&batchId=221

//Given a sorted array A of size N. The function remove_duplicate takes two arguments . The first argument is the sorted array A[ ] and the second argument is 'N' the size of the array and returns the size of the new converted array A[ ] with no duplicate element.

//solution
int remove_duplicate(int A[],int N)
{
set<int> v(A, A+N);
copy(v.begin(), v.end(), A);

return v.size();
}

0 comments on commit e596241

Please sign in to comment.