Data Structures & AlgorithmsHardInfosys · Wipro pattern

The words stop, pots, opts, post, tops, spot, pot, top are grouped so that anagrams share a group (key = the sorted letters). How many groups are there, and how big is the largest?

  1. A. 2 groups, largest 6
  2. B. 1 group, largest 8
  3. C. 3 groups, largest 4
  4. D. 2 groups, largest 4

Correct answer: A. 2 groups, largest 6

The six 4-letter words all sort to 'opst'; pot and top sort to 'opt'. Words of different lengths can never be anagrams, so the 3-letter ones form their own group: 2 groups, sizes 6 and 2. Grouping by the SET of letters would wrongly merge all eight into one group.

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

Exams that ask this topic