NatWest Group Interview Question

problem solving about a valid anagrams