The intuition for constructing and populating the table based on the recursive brute-force solution helped me greatly with solving other dynamic programming problems. Huge thanks buddy!
@jd32878 ай бұрын
you should fill out the table
@arnabpersonal67293 жыл бұрын
pretty good but why do we need a nth row
@ygongcode3 жыл бұрын
Because it is the terminal case. If you look at the recursive representation of this problem, the nth row is your recursion base case, aka root of the recursive tree and there are N levels of branches extending from the root. If you map it to the DP approach, one dimension of the table (# of rows, in this case) is effectively the height of your recursive tree, which is N+1.
@forrestjaustin42443 жыл бұрын
using nums = [1,1,1] is not a good clear example.. you should have used different numbers in the array