LeetCode
Numbers At Most N Given Digit Set
Click
here
for an explanation.