Dynamic Programming, Facebook Coding Interview, Google Coding Interview, Coding Interviews, Java.
0/1 Knapsack Input value[], weight[], Capacity Dp state dp[i][j] represents max sum of value we get by using items from 0 to i and bag of capacity j i = 0 to n j = 0 to Capacity dp[i][j] = dp[i-1][j] if j < weight[i] max(dp[i-i][j], value[i] + dp[i-1][j-weight[i]]) otherwise LCS longest common