Reported August 2026
ByteDancemath

Count Numbers with an Even Digit Count

Reported by candidates from ByteDance's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live ByteDance OA. Under 2s to a working solution.
Founder's read

The edge case that breaks a naive solution here is the top of the range. 10000 has five digits, so it's odd, and people who hardcode checks for 2 and 4 digits tend to miss it or botch the boundary. ByteDance reported this one in August 2026, and it's a quick math pass over an array. Count how many numbers have an even number of decimal digits. It looks too easy to fail, which is exactly why people get sloppy. If you blank on the digit counting during the live OA, StealthCoder runs invisibly as a safety net and gives you a clean solution fast.

The problem

Given an array of positive integers numbers, count how many elements 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 trick is digit counting, and you've got three clean options. Convert to a string and check if the length is even. Loop dividing by 10 and count the steps. Or use range checks: 10-99, 1000-9999. All are O(n) for the array, and the constraints make any of them instant. The pitfall is the boundary. Values run up to 10^4, so 10000 has five digits and must not count. Also watch 10 and 1000, the smallest values of their digit lengths, since off-by-one range checks tend to break there. Don't use log10 with floating point unless you're careful, because exact powers of ten can misround on some languages. The string length approach is the safest to write under pressure. If you freeze during the live ByteDance OA, StealthCoder is the hedge that reads the problem on screen and hands you the working code without the proctor seeing it.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as find numbers with even number of digits. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass ByteDance's OA.

ByteDance reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Numbers with an Even Digit Count FAQ

How hard is this ByteDance OA question really?+

It's easy. One pass over the array, one digit check per element. The only way to lose is a boundary mistake, usually with 10000 or with range checks that skip 10 or 1000. Write it, run both examples, then test the edges.

What's the trick to counting digits?+

Convert the number to a string and check whether its length is even. That's the least error-prone option. If you prefer pure math, divide by 10 in a loop and count iterations. Both pass easily given numbers.length is at most 1000.

Which edge cases should I test?+

Test 1 (one digit), 10 (two digits), 999 (three), 1000 (four), and 10000 (five). Example 2 covers all of these and expects 2. Also test an array with a single element, since length can be 1.

Is the range-check approach safe?+

Yes, if you get the bounds right. Count a number when it's 10-99 or 1000-9999. Anything else under the constraints is odd, including 10000. It's fast but easier to mistype than string length, so double-check your inequalities.

How do I prep for this in 48 hours?+

Don't over-prep. Write the solution once in your language with string length and once with a divide loop. Then spend remaining time on harder array and hash map problems, since ByteDance OAs usually include something tougher alongside an easy one like this.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with ByteDance.

OA at ByteDance?
Invisible during screen share
Get it