Data Structures & AlgorithmsVery hardProduct company OA · Amazon/Microsoft-style OA

Set A = {1, 2, 4, 7} and set B = {3, 5, 6, 8}. Choose two different elements from A and two different elements from B. How many choices give equal sums for the two pairs?

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

Correct answer: D. 4

Count the 2-element sums of A and of B with multiplicity, then multiply the counts for each equal sum. Counting distinct common sums misses the multiplicities.

More Coding Interview Problems questions

Exams that ask this topic