#K78357. Find All Anagram Indices
Find All Anagram Indices
Find All Anagram Indices
You are given two strings: a text string \( T \) and a pattern string \( P \). Your task is to find all starting indices in \( T \) where any anagram of \( P \) appears as a substring. In other words, you need to slide a window of length \( |P| \) over \( T \), and for each window, check if the multiset of characters matches that of \( P \).
Note: \( |T| \) denotes the length of string \( T \) and \( |P| \) denotes the length of string \( P \). The window positions are 0-indexed, and an anagram is any permutation of the characters of \( P \).
inputFormat
The input consists of two lines read from standard input (stdin):
- The first line contains the text string \( T \).
- The second line contains the pattern string \( P \).
outputFormat
Print to standard output (stdout) the list of starting indices where an anagram of \( P \) begins in \( T \). The indices should be printed in order and separated by a single space. If there are no such indices, output an empty line.
## samplecbaebabacd
abc
0 6