We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 03f3aab commit b4b30a4Copy full SHA for b4b30a4
solution/1155.Number of Dice Rolls With Target Sum/Solution.java
@@ -0,0 +1,14 @@
1
+class Solution {
2
+ public int numRollsToTarget(int d, int f, int target) {
3
+ int[] dp = new int[target + 1];
4
+ dp[0] = 1;
5
+ for (int i = 1; i <= d; ++i) {
6
+ for (int j = target; j >= 1; --j) {
7
+ for (int k = 1; k <= f && k <= j; ++k) {
8
+ dp[j] = (dp[j] + dp[j - k]) % 1000000007;
9
+ }
10
11
12
+ return dp[target];
13
14
+}
0 commit comments