-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepeatRemover.java
More file actions
28 lines (26 loc) · 855 Bytes
/
RepeatRemover.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
import java.util.*;
class RepeatRemover{
public Vector<Integer> remover(int[] input) {
Integer mask = 0;
Vector<Integer> output = new Vector<Integer>();
int j = 0;
for(int i=0; i<input.length; i++) {
Integer t = 1;
t = t << input[i];
if((mask & t) != 0) {
continue;
} else {
output.add(input[i]);
mask = mask | t;
}
}
return output;
}
public static void main(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 = new int[]{10000,10000,10000,10000,10000};
RepeatRemover rr = new RepeatRemover();
Vector<Integer> op = rr.remover(a);
System.out.println("Trimmed array is "+op);
}
}