Rakuten Interview Question

A question about going through anagrams.