Find Every Rearranged Copy of a Pattern

Asked at Snowflake · Coding Questions · Difficulty: Medium · Last asked Feb 21, 2026

Given a long text and a short pattern, find every place in the text where some rearrangement of the pattern's letters appears as a contiguous block. A block matches when it has exactly the same letters as the pattern with the same counts, in any order.

Loading the problem…