Count Integers That Appear Exactly Once
Company: Agoda
Role: Data Engineer
Category: Coding & Algorithms
Difficulty: easy
Interview Round: Technical Screen
Overview: Count distinct integers with frequency exactly one using complete occurrence counts, including empty arrays and separated duplicates.
Read the full Agoda Data Engineer interview experience this question came from
Constraints
- 0 <= len(numbers) <= 200000.
- Each value is an integer from -1000000000 through 1000000000.
- Repeated values do not contribute, regardless of where their occurrences appear.
- Return 0 for an empty array.
- Aim for expected O(n) time.
Examples
Input: ([],)
Expected Output: 0
Explanation: Empty array: no values at all, so the answer is 0.
Input: ([7],)
Expected Output: 1
Explanation: Singleton array: 7 occurs exactly once, so it contributes 1.
Hints
- The first time you meet a value tells you nothing final: the same value may appear again later in the array.
- Decide whether a value contributes only after the frequency of every value across the entire array is known.
- An empty array contains no values at all, so its answer is 0.