Back to course home
0% completed
Solution: Number of Dice Rolls With Target Sum
Problem Statement
You are given n
dice, each dice having k
faces numbered from 1
to k
. You are also given target
positive integer.
Return the number of ways you can roll the dice so that the sum
of the face-up
numbers equals the target
sum. Since the answer may be too large, return it modulo 10<sup>9</sup> + 7.
Examples
Example 1
- Input: n = 2, k = 4, target = 5
- Expected Output: 4
- Justification: The possible rolls are (1, 4), (2, 3), (3, 2), and (4, 1).
Example 2
- Input: n = 3, k = 6, target = 8
- Expected Output: 21
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible