Solve the checking substring anagrams problem in O(n).