

3,5 and 5,3 are not distinct combinations.
The first line of input contains an integer ‘T’ denoting the number of test cases.
The first and only line of each test case contains an integer ‘N’ , the total amount.
For each test case, return the number of distinct combinations to reach the total amount is printed.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 5 * 10^4
Time Limit: 1 sec
To count all possible distinct combinations to reach the total amount of ‘N’ using coins of 3,5 and 10, we can divide all solutions in two sets.
The total number of distinct combinations can be found using recursion.
Algorithm:
The idea is the same as the previous approach, but in the previous approach, many recursive calls were made again and again with the same parameters.
In the below diagram, the two parameters are : (coins array, total amount).

It is very clear that there are overlapping subproblems. This can be eliminated by storing the value obtained from a particular call in a 2d array, called the 'TABLE_ARRAY'.
'MEMO'[i][j] stores the count of distinct combinations which sums up to ‘i’ and once includes the jth coin and once excluding the ith coin.
Algorithm:
For every type of coin, go through all the amounts ‘j’ , such that 0 <= j <= N, and update the value of 'DP'[j] as 'DP'[j] = 'DP'[j] + 'DP'[j - value of current coin]. This will add the count of distinct combinations that sums up to ‘j’ and that includes the current type of coin. And 'DP'[j] already had some value which was the count of distinct combinations that sums up to ‘j’, but only includes the coin that has occurred before the current coin in the coins array. Thus, at this point, 'DP'[j] contains the count of distinct combinations that sums up to ‘j’ with and without including all the coins up to the current type of coin.
Algorithm: