-
Notifications
You must be signed in to change notification settings - Fork 0
/
prog6.java
45 lines (27 loc) · 834 Bytes
/
prog6.java
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
44
package arrayPrograms;
import java.util.LinkedHashMap;
import java.util.Map;
public class prog6 {
public static void main(String[] args)
{
int[] arr = { 1, 2, 5, 1, 7, 2, 4, 2 };
int n = arr.length;
removeDuplicate(arr);
}
public static void removeDuplicate(int []a) {
Map<Integer, Boolean> m=new LinkedHashMap<>();
System.out.println(m);
for(int i=0; i<a.length; i++) {
System.out.println(m.get(a[i]));
}
System.out.println();
for(int i=0; i<a.length; i++) {
if(m.get(a[i])==null) {
System.out.print(a[i]+" ");
m.put(a[i], true);
}
}
System.out.println();
System.out.println(m);
}
}