Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

From task sizes [4, 5, 6, 3], what is the largest number of tasks you can keep so that their total size is at most 10?

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

Correct answer: C. 2

Keep the smallest tasks first: 3 + 4 = 7 fits, and adding 5 gives 12 which exceeds 10, so two tasks is the best since three tasks cannot fit (3 + 4 + 5 = 12).

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

Exams that ask this topic