Problem Visual
bar[0]
foo[3]
the[6]
foo[9]
bar[12]
man[15]
You are given a string s and an array of strings words.
All strings in words have the same length.

A concatenated string exactly contains every string in words
in any permutation, back-to-back.

Return all starting indices in s where such concatenations appear.

Example 1:
Input: s = "barfoothefoobarman", words = ["foo","bar"]
Output: [0,9]

Explanation:
Index 0 -> "barfoo" = permutation of ["foo","bar"]
Index 9 -> "foobar" = permutation of ["foo","bar"]
Reasoning
Why: Before coding, we must lock down exactly what counts as a valid answer.
Decision: A valid answer is a contiguous block containing all words exactly once (any order).
Avoid: Guessing the pattern too early without understanding the rule.

Beginner: Given Problem

Read the problem slowly. Understand input, output, and example.

Detect Pattern Signals

Tap each signal card to see why this pattern fits.

Build the Plan

Edit words and watch the frequency map update live.

Scan by Offsets

Switch offsets (0,1,2) and see visited positions.

Window Updates

Use play/next/prev to run the algorithm state-by-state.

Complexity & Example

Move the size slider and compare brute force vs optimized.

Interactive Check

Name the right pattern before implementing.

Pattern Solved

You mapped cues to the right algorithm and built an optimized solution.
Reuse this same workflow for advanced string and hash-map questions.

AlgoAnimator: Interactive Data Structures