Find All Anagrams in a String

Given *s* and pattern *p*, find all start indices of *p*’s anagrams in *s*. Return list of indices.

Input Format

Two lines: s, then p.

Output Format

List of indices.

Constraints

  • len(s), len(p) <= 10^5.

Examples

Example 1:

Input:

s = "cbaebabacd"
p = "abc"

Output:

[0,6]

Explanation:

"abc" at 0-2, "bac" at 6-8.

Loading...
Find All Anagrams in a String - Strings