Skip to content
LakeBench
ProblemsCommunityPricing
Sign inStart practicing

Find All Anagrams

Python data engineering interview problem. Difficulty: intermediate. Pattern: Sliding Window. About 14 minutes. Part of the Pro drill bank.

Start indices of every anagram of p inside s. Treat this as a production helper: match the contracted return shape, including empty and duplicate inputs.

Implement find_anagrams(s: str, p: str) -> list returning start indices of anagrams of p in s, sorted ascending.

Requirements

  • Return indices in ascending order.

Constraints

  • Lowercase letters.

Examples

Input: find_anagrams('cbaebabacd', 'abc') Output: [0, 6] Windows at 0 and 6 match.

Topics: lakebench, python, anagram, indices.

More Python interview questions · All interview problems · Learn data engineering

intermediate

Find All Anagrams

Interview-style drill: Start indices of every anagram of p inside s.

Implement `find_anagrams(s: str, p: str) -> list` returning start indices of anagrams of p in s, sorted ascending. Example: `"cbaebabacd", "abc"` → `[0, 6]`. Keep the harness.