Participate in Codex, Test Your Skills & Win BIG

N digit numbers with digit sum S

Find out the number of N digit numbers, whose digits on being added equals to a given number S. Note that a valid number starts from digits 1-9 except the number 0 itself. i.e. leading zeroes are not allowed.

Since the answer can be large, output answer modulo 1000000007


N = 2, S = 4
Valid numbers are {22, 31, 13, 40}
Hence output 4.

NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.
Start solving N digit numbers with digit sum S  on Interview Code Editor
  • Hint 1
  • Solution Approach
  • Complete Solution


Click here to start solving coding interview questions