Pregunta de entrevista de MathWorks

Problem involving counting anagrams efficiently