Coding Quiz - 1, 2, 3 Addition
In this coding problem, you will write a function using Dynamic Programming (DP) to find the number of ways to form a specific number.
For a given number n, you need to calculate all the possible ways to make n with the sum of 1, 2, and 3.
For example, when n = 4, the possible combinations are 1+1+1+1, 1+1+2, 1+2+1, 2+1+1, 2+2, 1+3, and 3+1, totaling 7 ways.
Solution Code
def solution(n): # Write your code here return
Constraints
-
nis an integer between 1 and 10, inclusive. -
The result should be returned as an integer.
Example Input and Output
-
Input:
4 -
Output:
7
-
Input:
6 -
Output:
24
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help