Dice Combinations

Your task is to count the number of ways to construct the sum n by throwing a standard 6-sided dice one or more times. Each throw produces an outcome between 1 and 6.

Since the number of ways can be very large, return the answer modulo 109 + 7.

Example 1:

Input : 3

Output : 4

Explanation : The 4 ways to make sum 3 are: ((1,1,1), (1,2), (2,1), (3)).

Example 2:

Input : 2

Output : 2

Explanation : The 2 ways to make sum 2 are : ((1,1) , (2))

Now Your Turn!

Pick the correct output for the given input

Input : 4

Still unsure what the problem is asking ?

Letโ€™s go through a few more examples, step by step, to make it clearer.

Constraints:

  • 1 <= n <= 106

Hints

Frequently Occurring Doubts

Interview Follow-up Questions

0
class Solution {
public:
int countWays(int n) {
}
};
Test Case

Input:

N