Question bank › Dynamic Programming
Dsa Dynamic Programming Easy

Substring with Concatenation of All Words

Given a string s and an array of strings words of the same length, find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any intervening characters. The first line contains the string s, the second line contains an integer m (1 <= m <= 100), and the third line contains m space-separated words. Output all starting indices of the substring(s). Example: Input: barfoothefoobarman 3 a foo the Output: 0 9

Key concepts

dynamic_programmingstringhashing

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.