Medium · Strings
Find anagram substring indices
Given strings s and p of lowercase letters, return, in increasing order, every index i such that the substring of s of length |p| starting at i is an anagram of p (the same letters with the same counts); return an empty list if there is none.
Examples
Example 1
s="cbaebabacd", p="abc"Output: starts [0,6]
Example 2
s="abab", p="ab"Output: starts [0,1,2]
Rebuild it in the studio
Read every interview problem free. Ten rooms need no account. A token opens a problem in full — Pro never counts.