Katkat

Count Numbers with an Even Number of Digits

ByteDanceSoftware Engineer · Online Assessment

Last updated

Count how many positive integers in an array have an even number of decimal digits. Respect ordinary representations without leading zeroes, count repeated values independently, and handle boundaries such as 10 and 10000 correctly.

Problem

Given an array of positive integers, count how many elements have an even number of decimal digits.

Function Contract

Implement count_even_digit_numbers(numbers) -> int.

Constraints

  • 1 <= len(numbers) <= 1000.
  • 1 <= numbers[i] <= 10000.
  • Use the ordinary base-10 representation without leading zeroes.

Examples

  • [12, 134, 111, 1111, 10] returns 3.
  • [7, 10000] returns 0.

Edge Cases

  • A one-digit number is not counted.
  • The upper-bound value 10000 has five digits.
  • Repeated values count separately.

Hints

Hint 1

Count decimal places: Converting to a decimal string is sufficient under these bounds; repeated division by ten is another valid approach.