Count Numbers with an Even Digit Count
Reported by candidates from ZipRecruiter's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The data structure here is just a plain array and a counter, and that's the whole point. ZipRecruiter reported this OA in October 2023, and it's a warm-up: given positive integers, count how many have an even number of decimal digits. If you've been bracing for graphs or DP, relax. The risk isn't difficulty, it's overthinking or fumbling a trivial detail under a timer. Read the array once, test each value, bump a count. If your brain freezes anyway, StealthCoder runs invisibly during the live OA and can hand you the working solution so a silly blank doesn't cost you the round.
The problem
Given an array of positive integers numbers, count how many values have an even number of decimal digits. Return that count. Function countEvenDigitNumbers(numbers: int[]) → int Examples Example 1 numbers = [12, 134, 111, 1111, 10] return = 3 The values 12, 1111, and 10 have two, four, and two digits, respectively. Example 2 numbers = [1, 10, 999, 1000, 10000] return = 2 Only 10 and 1000 have an even number of digits. Constraints 1 <= numbers.length <= 1000 1 <= numbers[i] <= 10^4
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern is math on a single pass. For each number, get its digit count and check if it's even. Three clean ways: convert to a string and check the length, loop dividing by 10 and count steps, or use the constraint. With values from 1 to 10^4, even-digit numbers are only 10-99 and 1000-9999. So the check is (10 <= n <= 99) or (1000 <= n <= 9999). Time is O(n), space is O(1) for the math versions. The pitfall is 10000. It has five digits, so it's odd, and people who assume four-digit cap miscount it. Example 2 includes it on purpose. Also don't count 1 as even. Test your logic against both examples before submitting. If you blank on the digit-count idea during the live OA, StealthCoder is the hedge that surfaces a clean solution without the proctor seeing anything.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Count Numbers with an Even Digit Count cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as find numbers with even number of digits. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass ZipRecruiter's OA.
ZipRecruiter reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Count Numbers with an Even Digit Count FAQ
How hard is the ZipRecruiter even digit count question really?+
It's easy. One loop over up to 1000 numbers, one digit check, one counter. The only way to fail is a careless edge case, mainly 10000 having five digits. If you can write a for loop and a modulo check, you can pass this.
What's the trick to counting digits?+
Either convert the number to a string and check if the length is even, or repeatedly divide by 10 and count. Both work fine at this size. The range-check shortcut also works: 10-99 and 1000-9999 are the only even-digit values allowed by the constraints.
Which edge cases should I test?+
Test 1 (single digit, odd), 10 (two digits, even), 999 (three, odd), 1000 (four, even), and 10000 (five, odd). Example 2 already covers all of these, so run it by hand before you submit. A single-element array is also valid input.
Is this type of problem still asked in 2023 and beyond?+
Yes. Easy array and math warm-ups like this one were reported by ZipRecruiter candidates in October 2023. Companies use them as a screen to confirm you can code basic logic cleanly, often alongside harder questions in the same assessment.
How do I prepare in 48 hours for an OA like this?+
Don't grind hard problems for this one. Practice writing simple array loops fast in your chosen language, know how to get digit counts both ways, and rehearse reading constraints for edge cases. Spend the rest of your time on the harder questions likely to sit beside it.