Reported September 2026
TikTokmath

Count Even-Digit Numbers

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

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

The trap in the TikTok "Count Even-Digit Numbers" OA, reported in September 2026, is the boundary values, not the logic. Numbers like 9, 10, 99, 100 and 10000 are where a sloppy digit count falls apart. The task is simple: count how many elements in an array have an even number of digits. It's a math warm-up, and it's the kind of question you lose by rushing. If you blank on the digit-counting step during the live assessment, StealthCoder runs invisibly as a safety net and hands you the clean version. Otherwise, read the trick below and you won't need it.

The problem

Given an array of positive integers numbers, calculate how many of its elements have an even number of digits.
Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(numbers.length2) will fit within the execution time limit.

Function
solution(numbers: int[]) → int

Examples
Example 1
numbers = [12, 134, 111, 1111, 10]
return = 3
numbers[0] = 12 has 2 digits, which is an even number.
numbers[1] = 134 has 3 digits, which is not an even number.
numbers[2] = 111 has 3 digits, which is not an even number.
numbers[3] = 1111 has 4 digits, which is an even number.
numbers[4] = 10 has 2 digits, which is an even number.
There are 3 elements, numbers[0], numbers[3], and numbers[4], with an even number of digits.

Constraints
1 <= numbers.length <= 1000
1 <= numbers[i] <= 104

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is counting digits correctly. Three clean ways work. Convert to a string and check if the length is even. Loop dividing by 10 and count the steps. Or use ranges: 10-99 and 1000-9999 are even-digit, since the cap is 10^4. The pitfall is the top edge. 10000 has 5 digits, so it's odd, and people who hardcode ranges forget it. Another slip is using log10 with floating point, which can misround on exact powers of ten. Stick to string length or integer division. The note says O(n^2) is fine, so efficiency isn't the point. With n up to 1000, one pass is trivial. Test your code on [1, 10, 99, 100, 1000, 10000] before submitting. If the live assessment rattles you, StealthCoder is there as a hedge, but this one is a five-minute solve if you stay calm.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Count Even-Digit Numbers 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. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

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 TikTok's OA.

TikTok reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Count Even-Digit Numbers FAQ

How hard is the TikTok Count Even-Digit Numbers question really?+

It's easy. One pass over the array, count digits per number, increment a counter when the count is even. The only way to lose it is an edge-case slip on values like 10, 100 or 10000. Treat it as a speed-and-accuracy check, not a thinking check.

What's the trick to counting digits safely?+

Convert the number to a string and check whether its length is even. It avoids floating point issues from log10 and off-by-one errors in range checks. If you prefer math, divide by 10 in a loop and count iterations. Both are fine for values up to 10^4.

Which edge cases should I test before submitting?+

Test single-digit values like 1 and 9, which are odd. Test 10 and 99, which are even. Test 100 and 999, which are odd. Test 1000 and 9999, which are even. Finally test 10000, the max, which has 5 digits and is odd. Also try an array of length 1.

Do I need an optimal solution here?+

No. The problem says anything not worse than O(n^2) fits the limit. A single linear pass is already better than that, and n is at most 1000. Don't overengineer it. Write the simple loop, run your edge cases, and move on.

How do I prepare for this in 48 hours?+

Don't grind this one. Write the string-length version and the divide-by-10 version from memory once each. Then spend your time on other easy math and array problems, since TikTok OAs often pair a warm-up like this with something harder. Practice reading constraints carefully, especially the upper bound.

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

OA at TikTok?
Invisible during screen share
Get it