Level: Unknown Level
Round: Full Journey · Type: Coding · Difficulty: 6/10 · Duration: 60 min · Interviewer: Neutral
Topics: String Manipulation, Anagrams, Sliding Window
Location: San Francisco Bay Area
Interview date: 2026-01-05
Question: Find all anagrams of string p in string s.
The problem requires me to find all starting indices in string s where an anagram of string p begins. The length of both strings is between 1 and 30,000, and they consist of lowercase English letters.
For example:
If s = "cbaebabacd" and p = "abc", the output should be [0, 6] because "cba" (at index 0) and "bac" (at index 6) are anagrams of "abc".
If s = "abab" and p = "ab", the output should be [0, 1, 2] because "ab" (at index 0), "ba" (at index 1), and "ab" (at index 2) are anagrams of "ab".
LeetCode similar: LeetCode 438