Solution for Knapsack problem