Hi,
I'm trying to implement an unbounded knapsack problem.
It works just fine, in it's classic form (need to find the maximum
benefit by taking total weights < capacity of knapsack). However I
need it a little bit changed -- I need to find the minimum benefit
instead of maximum. If I try just t
dor is absolutely right
> O(N*log(N)) is straightforward.. sort the array in O(N*log(N)) and
> then remove duplicates in linear time.
it doesn't need any extra memory.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Group
Hi MD,
In your last approach, watch out for arbitrarily large values. What
would 'N' be? By the way, 'for' loop there should be for 'n', which is the
size of array 'a'. A simple array like {20, 5, 123456789} would kill your
memory.
Hashing approach would be great if we've some idea on nature of th