Data Structures & AlgorithmsModerateTCS NQT · Infosys

Problem: Boats carry at most 2 people and a weight limit of 10 per boat. Four people weigh 3, 5, 3 and 4. What is the minimum number of boats needed to carry everyone?

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

Correct answer: D. 2

Sort the weights and pair the heaviest remaining person with the lightest when the sum fits. Pairing the two heaviest first may waste capacity.

More Coding Interview Problems questions

Exams that ask this topic