Katkat

Count Numbers With Odd Zeros

Capital OneSoftware Engineer · Technical Screen

Last updated

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.

Given an array a of non-negative integers, count how many elements contain an odd number of digit '0' in their decimal representation.

Notes:

  • Treat the number 0 as having one zero digit.
  • Do not count leading zeros, since the numbers are given as integers.

Example:

  • Input: a = [20, 11, 10, 10070, 7]
  • Output: 3

Explanation:

  • 20 contains 1 zero
  • 11 contains 0 zeros
  • 10 contains 1 zero
  • 10070 contains 3 zeros
  • 7 contains 0 zeros

So there are 3 numbers with an odd number of zeros.