dynamic programming: knapsack problem dp and brute force solutions