|
|
back to boardDP with O(n*max(wi)) time and O(max(n, max(wi))) space There is a DP solution for this version of knapsack problem with O(n*max(wi)) time and O(max(n, max(wi))) space. It's a beat tricky, but still not so difficult in implementation. Just use your brains wisely ;) But an easy one is a brute-force, where we need to search between 2^n sets of piles. P.S. To admins, how about adding a new problem "Stone Pile 2" with N<=1000, 1<=Wi<=10000 and with writing the exact piles to output :) |
|
|