Rakuten interview question

A question about going through anagrams.