Find All Anagrams in String

Medium
Strings String Sliding Window Hash Table

Find all start indices of p's anagrams in s.

Constraints

1 ≤ lengths ≤ 3×10^4

Examples

Example 1:
Input: cbaebabacd abc
Output: 0 6
Example 2:
Input: abab ab
Output: 0 1 2
▲ Console

Install Talent Arabia

Get instant access to jobs and career tools on your device.