-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepeatRemover.cpp
More file actions
44 lines (40 loc) · 818 Bytes
/
repeatRemover.cpp
File metadata and controls
44 lines (40 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<iostream>
#include<vector>
using namespace std;
class RepeatRemover {
private:
vector<int> op;
public:
RepeatRemover(){
// op = new vector<int>();
cout << "Constructor" << endl;
}
void remover(int a[], int length) {
int mask = 0;
int i;
for (i=0; i<length; i++) {
int t = 1;
t = t << a[i];
if(mask & t) {
continue;
} else {
op.push_back(a[i]);
mask = mask | t;
}
}
}
void print_vector(){
vector<int>::iterator it;
for(it = op.begin() ; it != op.end(); ++it) {
cout << *it << " ";
}
}
};
int main(){
RepeatRemover rr;
int a[] = {1000,1000,65548,684784,684784};
int length = 5;
rr.remover(a, length);
rr.print_vector();
return 0;
}