Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

How many unordered pairs of words in ["listen", "silent", "enlist", "google", "gogole", "cat", "act"] are anagrams of each other?

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

Correct answer: C. 5

Group words by their sorted letters (a hash key) and add C(k, 2) per group. Groups here are of sizes 3, 2 and 2.

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

Exams that ask this topic