#C12927. 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 start indices of (p)'s anagrams in (s). An anagram is a rearrangement of letters. For example, the anagrams of (abc) are (abc), (acb), (bac), (bca), (cab), and (cba). The indices should be output in ascending order.
Input is read from standard input and output should be printed to standard output. In particular, the first line contains the string (s) and the second line contains the string (p).
inputFormat
The input consists of two lines.
Line 1: A string (s) in which you need to find the anagrams of (p).
Line 2: A string (p) whose anagrams you are looking for.
outputFormat
Output a single line containing the starting indices (0-indexed) of every occurrence of an anagram of (p) in (s). The indices must be printed in ascending order separated by a single space. If there are no anagrams, print an empty line.## sample
cbaebabacd
abc
0 6