Q. How to figure out the dimension of the Memoization array? A. how many varaibles are modified inside the recursive calls? 1=> then it will be an array, list, set, etc... 2=> then it will be a m*n Matrix which is two dimensional.
- draw the brute-force recursion tree
- list all the possible values
- in each branch draw to include or not to include the currenr choice
- try to figure out the sub-problems from the tree
- try to write a self contained recursive function which means all the needed variables for the calculation are passed as local variables
- no static global varaibales, no tail recursion
- figure out the base case and termination condition
- iterate over the array of choices
- can we include the current choice or does it violate the boundary, if it does recursively call the function with index+1 no change in the target value
- we can include the current choice since it does not violate the boundary but do we want to a. figure out the maximum of inclusion and exclusion b. include target-sum- current and index, out targets-um -0 and index+1
for LCS, we have two strings and two pointers and one length so we need a three dimensional array that keeps indexes and length also we have three recursive calls
we can use a hashmap instead of the three dimensional array. so the key will be the concatnation of index1 and index2