Showing posts with label Knapsack. Show all posts
Showing posts with label Knapsack. Show all posts

Thursday, October 20, 2011

Provide an efficient algorithm to solve the question "Can I buy N items?

 A shop sells an item in packets of 6, 9, and 17. A customer can buy any number of packets, but a packet cannot be broken up. Provide an efficient algorithm to solve the question "Can I buy N items?". For example, is it possible to buy 29 items? What about 19? Your algorithm simply needs to return true or false.