Data Structures & AlgorithmsHardProduct company OA · Amazon/Microsoft-style OA

Four groups are G1 = {1, 4}, G2 = {2, 9}, G3 = {3, 7} and G4 = {5, 6}. Choosing exactly one element from each group, how many choices sum to 14?

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

Correct answer: B. 1

Combine groups one and two into all 4 sums, combine groups three and four into all 4 sums, and count complementary pairs using a counter. The pair count is over choices, so repeated sums must be counted with multiplicity.

More Coding Interview Problems questions

Exams that ask this topic