BMW Group Interview Question

It was a question of optimizing a code that was about anagrams.