Files

32 lines
799 B
Java
Raw Permalink Normal View History

2017-03-10 01:10:37 -06:00
// Author: Rodney Shaghoulian
2018-07-27 16:45:56 -07:00
// Github: github.com/RodneyShag
// HackerRank: hackerrank.com/RodneyShag
2017-03-10 01:10:37 -06:00
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);
}
}