07. Dice Throw
β GFG solution to Dice Throw: count number of ways to get target sum using n dice with m faces using dynamic programming. π
π§© Problem Description
π Examples
Example 1
Input: m = 6, n = 3, x = 12
Output: 25
Explanation: There are 25 total ways to get the sum 12 using 3 dice with faces from 1 to 6.Example 2
Input: m = 2, n = 3, x = 6
Output: 1
Explanation: There is only 1 way to get the sum 6 using 3 dice with faces from 1 to 2.
All the dice will have to land on 2.Example 3
π Constraints
β
My Approach
1D DP with Backward Iteration
π Time and Auxiliary Space Complexity
π§βπ» Code (C++)
β Code (Java)
π Code (Python)
π§ Contribution and Support
πVisitor Count
Last updated