Data Structures & AlgorithmsVery hardTCS NQT · Accenture

How many distinct anagram classes are there among the words eat, tea, tan, ate, nat and bat (two words are in the same class if one is a rearrangement of the other)?

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

Correct answer: A. 3

Sort each word's letters to get a canonical key: aet (eat, tea, ate), ant (tan, nat), abt (bat). Three keys give three classes.

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

Exams that ask this topic