#C14925. Find All Anagram Indices

    ID: 44628 Type: Default 1000ms 256MiB

Find All Anagram Indices

Find All Anagram Indices

Given two strings \( s \) and \( p \), find all start indices in \( s \) where an anagram of \( p \) begins. An anagram of \( p \) is any permutation of its characters. The answer should be output as a list of indices in ascending order.

Note: Both \( s \) and \( p \) consist only of lowercase English letters.

Input Format

The input is read from standard input: the first line contains the string \( s \) and the second line contains the string \( p \).

Output Format

Print the start indices separated by a single space. If there are no valid indices, print nothing.

inputFormat

Two lines from standard input:

  • The first line is the string \( s \).
  • The second line is the string \( p \).

outputFormat

Print one line to standard output containing the space-separated indices where an anagram of \( p \) starts in \( s \). If no anagram is found, output an empty line.

## sample
cbaebabacd
abc
0 6