-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathSolution.java
More file actions
29 lines (25 loc) · 710 Bytes
/
Copy pathSolution.java
File metadata and controls
29 lines (25 loc) · 710 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
// github.com/RodneyShag
import java.util.Scanner;
import java.util.HashSet;
public class Solution {
public static void main(String[] args) {
/* Read some input */
Scanner scan = new Scanner(System.in);
int n = scan .nextInt();
/* Count pairs */
HashSet<Integer> set = new HashSet();
int pairs = 0;
for (int i = 0; i < n; i++) {
int cost = scan.nextInt();
if (set.contains(cost)) {
set.remove(cost);
pairs++;
} else {
set.add(cost);
}
}
/* Print output */
scan.close();
System.out.println(pairs);
}
}