The problem. Given strings s and p of lowercase letters, return the start index of every substring of s that is an anagram of p, in any order.
s = "cbaebabacd", p = "abc" -> [0, 6]
s = "abab", p = "ab" -> [0, 1, 2] (windows may overlap)Members only · free account
The rest of this lesson, with 6 more sections, 1 drawing, a dry-run simulator and code in JavaScript, Python, Java and C++, opens with a free account.
Not ready yet? The Arrays course is free to read, no account needed.
In the rest of this lesson