#C14328. Find All Anagrams in a String
Find All Anagrams in a String
Find All Anagrams in a String
Given two strings ( s ) and ( p ), your task is to find all the starting indices of ( p )'s anagrams in ( s ). An anagram is a permutation of characters. You need to output all indices in ascending order, separated by a single space. The input is provided via standard input and the output should be written to standard output.
For example, if ( s = \texttt{cbaebabacd} ) and ( p = \texttt{abc} ), then the output should be ( 0 6 ) because the substrings starting at indices 0 and 6 are anagrams of ( p ).
inputFormat
The input consists of two lines. The first line contains the string ( s ) and the second line contains the string ( p ). Both strings consist of lowercase English letters.
outputFormat
Output a single line with the starting indices of ( p )'s anagrams in ( s ), separated by a single space. If no anagrams exist, output an empty line.## sample
cbaebabacd
abc
0 6