Quick Overview

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.

Count Numbers With Odd Zeros

Company: Capital One

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

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.

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.

Given an array `a` of non-negative integers, return how many elements contain an odd number of digit `'0'` in their decimal representation. Important rules: - Treat the number `0` as having one zero digit. - Do not count leading zeros, since the values are given as integers. Example: - `a = [20, 11, 10, 10070, 7]` - `20` has 1 zero, `11` has 0, `10` has 1, `10070` has 3, `7` has 0 - So the answer is `3`.

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.

Hints

  1. 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.
  2. You only need to know whether the zero count is odd or even, so you can track parity instead of storing the full count.

Loading coding console...