adds memoization to knapsack
dyanmic programming and trie