Data Structures & AlgorithmsModerateTCS NQT Digital · Infosys

Problem: The words "listen", "silent", "enlist", "google", "gogole", "cat", "act", "tac", "dog" are grouped by anagram class (words with identical letter multisets). How many groups contain more than one word?

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

Correct answer: B. 3

Sort each word's letters to form a canonical key, then group by it. Grouping by length alone merges unrelated words such as 'dog' with 'cat'.

More Coding Interview Problems questions

Exams that ask this topic