Click here to Skip to main content
15,742,400 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
coding Problem link
i know that we need 2-d array to store the intermediate result to be later used by recursion, because 2 parameters are changing hence 2D array.
What i dont understand is what each cell will represent, like in Fibonacci DP we need an array and each cell represent the fibonacci of the index but here in this question what does it represent?
the instructor in the solution video just solves it using tabular method so its no use as of now.

What I have tried:

i have coded the basic recursion without DP but have no idea who to proceed with the DP storage and what a cell represent
<pre>public class coinChangeCombination {
    public static void main(String[] args){
        int[] coins = {2, 3, 5, 6};
        int target = 7;
        System.out.println(coinRecursive(0, target, coins, 0));

    //basic recursion
    public static int coinRecursive(int current, int target, int[] coins, int index){
        if(current > target) return 0;
        if(current == target) return 1;
        int count = 0;
        for(int i = index; i < coins.length; i++){
            int res = coinRecursive(current+coins[i], target, coins, i);
            count += res;
        return count;
Updated 13-Jun-21 4:39am

1 solution

How to get intuition for a specific DP problem

Probably the same way as one guess winning numbers of LOTTO.
There is no intuition in finding solution to a problem, there is only experience.
If a new problem is equivalent to a previously encountered problem, the same solution will apply, this is experience.
If a new problem is very similar to a previously encountered problem, first look to variations on solution of previous problem, this experience too.
Otherwise, fall back to standard solution : Solve the problem by hand with different inputs until you understand well the algorithm to solve the problem. Once you got a solution, see if you can improve the solution.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900