Reported July 2025
Metamath

Most Frequent Reduced Digit

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

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

Meta reported this one in July 2025, and it looks friendlier than it is. Repeatedly sum the digits of each sensor reading until it's one digit, then return the most frequent result, with ties going to the larger digit. The first sentence is easy. The edge cases are where a naive solution falls apart: zeros, single-digit inputs, and the tie-break rule. If you blank during the assessment, StealthCoder is the safety net running invisibly on your screen. But you probably won't need it once you see the trick.

The problem

You are working with data collected from various sensors. Given an array of non-negative integers readings, repeatedly replace each value with the sum of its decimal digits until every value is a single digit.
Return the most frequent digit in the final transformed array. If several digits have the same highest frequency, return the highest such digit.
A solution with time complexity no worse than O(readings.length^2) will fit within the execution time limit.

Function
solution(readings: int[]) → int

Examples
Example 1
readings = [123,456,789,101]
return = 6
123 becomes 1 + 2 + 3 = 6.
456 becomes 4 + 5 + 6 = 15, then 1 + 5 = 6.
789 becomes 7 + 8 + 9 = 24, then 2 + 4 = 6.
101 becomes 1 + 0 + 1 = 2.
The final array is [6,6,6,2], so the most frequent digit is 6.
Example 2
readings = [6]
return = 6
The reading 6 is already a single digit, so the final array remains [6] and the result is 6.

Constraints
Every value in readings is a non-negative integer.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The pattern is math, specifically the digital root. Repeated digit sums collapse to 1 + (n - 1) % 9 for n > 0, and 0 stays 0. So you skip the loop and map every reading straight to a digit, then count in a 10-slot array. The pitfall is the formula applied to 0, which gives 1 instead of 0 if you forget the guard. The second pitfall is the tie-break. Scan counts from 9 down to 0 and only replace the best on a strictly greater count, or scan upward and use greater-or-equal. The brute-force loop also passes, since the stated bound allows O(n^2), but the formula is cleaner and harder to bug. If you freeze on the digital root idea in the live OA, StealthCoder can surface it, but write the zero guard yourself.

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 Most Frequent Reduced Digit 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

⏵ The honest play

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

Meta 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.

Most Frequent Reduced Digit FAQ

What's the trick in Most Frequent Reduced Digit?+

Use the digital root. For any positive n, repeated digit sums end at 1 + (n - 1) % 9. Zero stays zero. Compute that for each reading, count the results in an array of size 10, and pick the best count. It avoids simulating the repeated sums entirely.

What edge cases break a naive solution here?+

Zero is the big one, since the digital root formula returns 1 for 0 unless you special-case it. Also watch single-digit inputs, which should stay unchanged, and ties. Example 1 has a clear winner, but you need the higher digit when counts match.

Can I just simulate the digit sums instead?+

Yes. The problem states O(readings.length^2) is acceptable, and each reduction is only a few iterations per number. A while loop that sums digits until the value is below 10 works fine. The formula is shorter, but simulation is a safe fallback if you don't trust your modulo math.

How do I handle the tie-break correctly?+

Loop digits from 9 down to 0 and update your answer only when the count is strictly greater than the current best. That way the highest digit wins any tie. Or loop 0 to 9 and update when the count is greater than or equal to the best.

How do I prepare for this Meta OA in 48 hours?+

Don't grind broadly. Write this problem twice, once with simulation and once with the digital root formula. Test it on [0], [6], and a tie like [1,2]. Then practice counting arrays and tie-break loops. That covers the whole shape of this question.

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

OA at Meta?
Invisible during screen share
Get it