Data Structures & AlgorithmsHard

What is the minimum number of positive integers (each value at most 10, repetitions allowed in the array) needed so that EVERY integer from 1 to 10 is the sum of some subset of them, each element used at most once?

  1. A. 3
  2. B. 5
  3. C. 10
  4. D. 4

Correct answer: D. 4

Binary-style reasoning shows that 1, 2, 4 cover only up to 7, so a fourth element is needed to reach 10. A brute check over multisets confirms that four values such as 1, 2, 4, 4 reach every target from 1 to 10.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic