Search
⌘K

Leetcode 902. Numbers At Most N Given Digit Set

Count how many positive integers you can form (with unlimited repeats from a given set of allowed digits) that are <= n. This is solved with combinatorics/digit-DP: sum all possibilities with fewer digits and then process n's digits left-to-right, counting allowed choices smaller at each position and stopping if a digit of n isn't available.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Your account is free and you can post anonymously if you choose.