HARDasked at 2 companies

Numbers With Repeated Digits

A hard-tier problem at 43% community acceptance, tagged with Math, Dynamic Programming. Reported in interviews at J.P. Morgan and 1 others.

Founder's read

Numbers With Repeated Digits is a hard combinatorics problem that looks like pure math but demands DP thinking. It's appeared in J.P. Morgan and IBM assessments. The problem asks you to count integers up to N with all unique digits, which sounds straightforward until you realize brute force times out and the math alone isn't enough. You need to combine digit DP with combinatorial counting to avoid TLE. The 43% acceptance rate reflects that most candidates either overthink the math or implement DP wrong. If this problem hits your live OA and you blank on the digit-by-digit construction trick, StealthCoder solves it in seconds, invisible to the proctor.

Companies asking
2
Difficulty
HARD
Acceptance
43%

Companies that ask "Numbers With Repeated Digits"

If this hits your live OA

Numbers With Repeated Digits is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.

Get StealthCoder
What this means

The trap is thinking you can just count permutations directly. The real solution builds numbers digit by digit from left to right, tracking which digits you've used. For each position, you count how many valid numbers you can form with the remaining digits and positions. The key insight: once you place a digit strictly less than the corresponding digit in N, all remaining digits can be anything from your unused set. That's where the combinatorial math kicks in. Most candidates either miss the digit-DP state transition or botch the permutation math when calculating remaining possibilities. The constraint that N can be large (10^9+) means you can't iterate through all numbers. You need to compute the answer by analyzing N's digit structure. StealthCoder is the hedge if you freeze on how to merge the DP framework with the combinatorial counting in real time.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Numbers With Repeated Digits recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Numbers With Repeated Digits interview FAQ

How hard is this really compared to other hard problems?+

The acceptance rate of 43% is on the lower end for hard problems, suggesting it's not pure brute-force territory. The difficulty lives in the hybrid skill set: you need both digit DP fluency and combinatorial math. Most candidates can handle one or the other, not both under time pressure.

Is this still asked at big tech?+

It's appeared at J.P. Morgan and IBM according to the data. It's less common in FAANG hiring but shows up in fintech and enterprise tech OAs. If you're interviewing at a company with a quantitative or algorithmic flavor, this problem class is worth knowing.

What's the core trick I'm missing?+

The trick is constructing numbers digit by digit and knowing when you have freedom. Once you place a digit smaller than N's digit at that position, every remaining digit can be any unused digit in any order. That's when factorial and combinations matter. Most misses happen because candidates don't realize permutation logic applies only in the 'free' part of the number.

Does this relate to other digit DP problems?+

Yes. It's in the same family as counting numbers with specific digit properties. Topics Math and Dynamic Programming both matter equally. If you've drilled digit DP for range-sum problems, you're partway there, but you still need to integrate combinatorial counting, which is a step most digit DP problems don't require.

Why do most people fail this?+

Time pressure breaks most attempts. The problem looks like a pure math puzzle, so people try to solve it combinatorially without DP. Or they build the DP but forget to use factorials and permutation math for the free digits. Getting both right in 30 to 45 minutes is genuinely hard, which the acceptance rate confirms.

Want the actual problem statement? View "Numbers With Repeated Digits" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.