14,979,090 members
1.00/5 (1 vote)
See more:
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()
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;
}
}```
Posted
Updated 13-Jun-21 4:39am

## Solution 1

Quote:
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.