- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepeatRemover.java
More file actions
Latest commit
28 lines (26 loc) · 855 Bytes
/
Copy pathRepeatRemover.java
File metadata and controls
28 lines (26 loc) · 855 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
importjava.util.*;
classRepeatRemover{
publicVector<Integer> remover(int[] input) {
Integermask = 0;
Vector<Integer> output = newVector<Integer>();
intj = 0;
for(inti=0; i<input.length; i++) {
Integert = 1;
t = t << input[i];
if((mask & t) != 0) {
continue;
} else {
output.add(input[i]);
mask = mask | t;
}
}
returnoutput;
}
publicstaticvoidmain(String[] args) {
// int[] a = new int[] {4,5,6,7,8,4,5,6,255,105,255,4200,10200,4200,10200, 65538, 65538};
int[] a = newint[]{10000,10000,10000,10000,10000};
RepeatRemoverrr = newRepeatRemover();
Vector<Integer> op = rr.remover(a);
System.out.println("Trimmed array is "+op);
}
}