Count Numbers With Odd Zeros
Capital OneSoftware Engineer · Technical ScreenLast 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
0as 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:
20contains 1 zero11contains 0 zeros10contains 1 zero10070contains 3 zeros7contains 0 zeros
So there are 3 numbers with an odd number of zeros.
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.