-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathu1.java
More file actions
29 lines (27 loc) · 890 Bytes
/
Copy pathu1.java
File metadata and controls
29 lines (27 loc) · 890 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
import java.util.Scanner;
import java.util.ArrayList;
public class u1 {
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int n;
System.out.println("enter no. of inputs : ");
n=s.nextInt();
int ar[]=new int[n];
for(int i=0;i<n;i++){
System.out.println("enter the element : "+i);
ar[i]=s.nextInt();
}
ArrayList<Integer> list=new ArrayList<>();
for(int i=0;i<n;i++){
int currentElement = ar[i];
if (list.contains(currentElement)) {
list.remove(Integer.valueOf(currentElement)); // Remove by value
} else {
list.add(currentElement);
}
}
for(int i=0;i<list.size();i++){
System.out.println(list.get(i));
}
}
}