Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

How many unordered pairs of distinct words in ["abc", "aba", "cdc", "xyz", "axa", "cd"] share both the same first letter and the same last letter?

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

Correct answer: C. 1

Only aba and axa share the key (first letter a, last letter a), so there is exactly one pair.

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

Exams that ask this topic