Problem - You have Given some weights and a value W such that you have to put that weights in boxes which can hold upto W weight per box . What is the minimum number of boxes required such that all the weights can be accumulated .
Eg - N = 5 , W = 5
w[] = { 1 , 2 , 3 , 4 , 5 }
ans = 3
{ 1 , 4 } { 2 , 3 } { 3 }
I tried two pointer approach which works greedily but it won’t worked
What could be a DP solution then ??
also
Does Greedy solution also works fine in this case ( supposing that I made some mistake while writing solution ) ?
Or any testcase that contradicts greedy solution ?