Count Numbers with an Even Number of Digits
Company: ByteDance
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Online Assessment
Overview: 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.
Read the full ByteDance Software Engineer interview experience this question came from
Constraints
- 1 <= len(numbers) <= 1000.
- 1 <= numbers[i] <= 10000.
- Use the ordinary base-10 representation without leading zeroes.
- Repeated values count separately.
Examples
Input: ([12, 134, 111, 1111, 10],)
Expected Output: 3
Explanation: This is the first source example; 12, 1111, and 10 have even digit counts.
Input: ([7, 10000],)
Expected Output: 0
Explanation: This is the second source example; one and five digits are both odd.
Hints
- Count decimal places by converting to a decimal string or repeatedly dividing by ten.