Practice Dice Roll Simulation
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
A die simulator generates a random number from 1 to 6 for each roll. You introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times. Given an array of integers rollMax and an integer n, return the number of distinct sequences that can be obtained with exact n rolls. Since the answer may be too large, return it modulo 10^9 + 7. Two sequences are considered different if at least one element differs from each other.
Source: Dice Roll Simulation on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
n = 2, rollMax = [1,1,2,2,2,3]
34
# Example 2
n = 2, rollMax = [1,1,1,1,1,1]
30
# Example 3
n = 3, rollMax = [1,1,1,2,2,3]
181
Constraints
Related LeetCode Problems
Practice more problems similar to Dice Roll Simulation.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.