Implement array parity and tree level views
Company: Meta
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
Quick Answer: This question evaluates proficiency in array frequency analysis and binary tree traversal, testing skills in data structures, correctness reasoning, and algorithm implementation.
Part 1: Check Whether All Array Elements Appear an Even Number of Times
Constraints
- 0 <= len(nums) <= 100000
- -10^9 <= nums[i] <= 10^9
Examples
Input: []
Expected Output: True
Explanation: The array is empty, so there are no values with odd frequency.
Input: [2, 2, 3, 3, 4, 4]
Expected Output: True
Explanation: Each distinct number appears exactly twice.
Input: [1, 2, 2, 1, 3]
Expected Output: False
Explanation: 1 appears twice and 2 appears twice, but 3 appears once, which is odd.
Input: [-1, -1, -2, -2, -2, -2]
Expected Output: True
Explanation: -1 appears twice and -2 appears four times; both are even counts.
Input: [7]
Expected Output: False
Explanation: 7 appears once, which is an odd frequency.