Count Numbers
Reported by candidates from Bloomberg's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Bloomberg hit you with a counting problem in September 2024, and you've got less than 72 hours. Counting problems look simple on the surface but hinge on recognizing a hidden pattern or constraint that makes brute force fail. You're probably dealing with a problem where iterating through every number in a range is too slow, and the real win is math or digit DP. StealthCoder will catch the pattern if you blank and give you a working scaffold during the live OA.
Pattern and pitfall
Count problems typically ask you to find how many numbers in a range satisfy a condition. The catch: the range is huge (1 to 10^18), so you can't loop. You need either digit dynamic programming, math-based counting, or a clever observation about the constraint. Bloomberg favors digit DP and mathematical counting patterns because they reward algorithmic thinking over brute force. Common pitfalls include mishandling edge cases, off-by-one errors in range logic, and forgetting to account for leading zeros. During the live assessment, if the logic isn't clicking, StealthCoder gives you a reference implementation to decode and adapt in real time.
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 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
You've seen the question.
Make sure you actually pass Bloomberg's OA.
Bloomberg 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 FAQ
Is this a digit DP problem or pure math?+
Most Bloomberg counting problems are digit DP, where you build numbers digit-by-digit and track state (position, constraints, leading zeros). Some use pure combinatorics. You'll know within 10 minutes of reading the constraint. If the range is massive (10^18), it's DP. If it's about mathematical patterns, it's formula-driven.
What's the most common mistake on counting problems?+
Off-by-one errors and mishandling the boundary cases (inclusive vs. exclusive ranges). Also, candidates forget to handle leading zeros when building numbers digit-by-digit. Test your logic on small ranges first. If count(1, 10) matches manual count, you're on the right track.
Can I brute force a counting problem?+
Not if the range is above 10^6 or 10^7. Bloomberg's OA is timed, and brute force will time out. Assume you need DP or math. If the naive approach passes, you're either lucky or the problem is easier than expected.
How do I prepare for a counting problem in 48 hours?+
Learn the digit DP template (recursive function with memoization, tracking position and constraint state). Practice on 2-3 classic counting problems (count numbers with specific digit sums, count numbers in a range with no repeated digits). Pattern recognition matters more than memorization.
What if I don't recognize the pattern during the OA?+
Start with the brute force on a small input to understand the problem. Write it down, then look for where it breaks. Usually the constraint will hint at the solution (huge range = DP, math relationship = formula). If you're stuck, a live scaffold is worth more than guessing.