Remove duplicates in small prime array
Easy Accuracy: 37.25% Submissions: 7876 Points: 2

Given an array consisting of only prime numbers, remove all duplicate numbers from it. 
Note: Retain the first occurrence of the duplicate element.

Example 1:

N = 6
A[] = {2,2,3,3,7,5}
Output: 2 3 7 5
Explanation: After removing the duplicate
2 and 3 we get 2 3 7 5.

Your Task:
Complete the function removeDuplicate() that takes given array and N as input parameters and returns modified array which has no duplicates.

Note: In case of cpp the return type is vector<int>

Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).


to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.