MathWorks interview question

Problem involving counting anagrams efficiently