Count Numbers With Odd Zeros
Company: Capital One
Role: Software Engineer
Category: Coding & Algorithms
Interview Round: Technical Screen
Quick Answer: This question evaluates proficiency in numeric digit analysis and parity-based counting, testing the competency to reason about decimal representations of integers within the Coding & Algorithms domain at a practical application level. It is commonly asked to assess basic algorithmic thinking, efficient iteration and counting skills, and careful handling of edge cases in technical interviews.
Constraints
- 0 <= len(a) <= 100000
- 0 <= a[i] <= 1000000000
Examples
Input: ([20, 11, 10, 10070, 7],)
Expected Output: 3
Explanation: 20 has 1 zero, 10 has 1 zero, and 10070 has 3 zeros. These are the three numbers with an odd zero count.
Input: ([],)
Expected Output: 0
Explanation: An empty array contains no numbers, so the count is 0.
Input: ([0],)
Expected Output: 1
Explanation: The number 0 is treated as having one zero digit, which is odd.
Input: ([1010, 909, 123, 1000],)
Expected Output: 2
Explanation: 1010 has 2 zeros, 909 has 1, 123 has 0, and 1000 has 3. Only 909 and 1000 have an odd number of zeros.
Input: ([5, 70, 700, 7000, 0],)
Expected Output: 3
Explanation: 70 has 1 zero, 700 has 2, 7000 has 3, and 0 has 1. The numbers 70, 7000, and 0 qualify.
Hints
- Process each number digit by digit and count how many times digit 0 appears. Remember that the number 0 itself should count as one zero.
- You only need to know whether the zero count is odd or even, so you can track parity instead of storing the full count.