#C14936. All Elements Even Frequency
All Elements Even Frequency
All Elements Even Frequency
Given an array of integers, determine whether every distinct element in the array appears an even number of times. In other words, for every integer x in the array, its frequency should satisfy the equation: $$frequency(x) \mod 2 = 0$$. If this condition is met for every element, output True
, otherwise output False
.
Examples:
- Input: [2, 4, 2, 4] → Output: True
- Input: [3, 3, 4, 4, 4] → Output: False
- Input: [] → Output: True
You need to read input from standard input and write the result to standard output.
inputFormat
The first line of input contains a single integer n (0 ≤ n ≤ 106), which indicates the number of elements in the array. The second line contains n space-separated integers representing the array.
outputFormat
Output a single line: True
if every element in the given array occurs an even number of times, otherwise output False
.
4
2 4 2 4
True