I know how to solve knapsack 0-1 problem with dynamic programming approach, but I am having troubles figuring out which items to take without compromising the complexity of O(N * C) (N items, C capacity).
Any ideas (I would prefer a bottom-up approach)?

Suppose, right now you're storing results in array
bool[] a, wherea[i]is true when sumican be achieved.You'll need another array
int[] b, whereb[i]is a last element you've placed into knapsack to achieve sumi.So, where you had
you'll need
Then, finding which items can be taken to achieve sum
iis a simple loop.PS I use two arrays for simplicity, but obviously array
acan be removed.