Data Structures & AlgorithmsHardTCS NQT · CAT · MBA placement

Pick one number from each of the lists [4, 9, 2], [7, 3, 8] and [5, 6, 1]. The three picks must sum to at most 14. What is the largest possible sum?

  1. A. 13
  2. B. 17
  3. C. 14
  4. D. 23

Correct answer: C. 14

Sort each list and combine with a two-pointer or binary search for the best pair under the leftover budget; trying all triples works for these small lists. Taking the largest value from each list ignores the budget entirely.

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

Exams that ask this topic