Data Structures & AlgorithmsVery hardICPC regional · Amazon SDE OA

What is the sum of lcm(a, b) over all unordered pairs of distinct positions in [2, 3, 4, 6]?

  1. A. 11
  2. B. 80
  3. C. 46
  4. D. 61

Correct answer: C. 46

Pairs give lcm values 6, 4, 6, 12, 6, 12 in some order, which total 46. The product of the pair is the trap whenever the values share a factor.

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

Exams that ask this topic