Substring with Concatenation of All Words || Leetcode Hard 30 || Sliding Window Problem

Опубликовано: 19 Март 2026
на канале: Digital Interview
713
10

You are given a string s and an array of strings words of the same length. Return all starting indices of substring(s) in s that is a concatenation of each word in words exactly once, in any order, and without any intervening characters.

You can return the answer in any order.



Example 1:

Input: s = "barfoothefoobarman", words = ["foo","bar"]
Output: [0,9]
Explanation: Substrings starting at index 0 and 9 are "barfoo" and "foobar" respectively.
The output order does not matter, returning [9,0] is fine too.
Example 2:

Input: s = "wordgoodgoodgoodbestword", words = ["word","good","best","word"]
Output: []

Get notified about all off campus jobs/interviews and the process.
We are building our website and it will be back soon with lots of content till then subscribe us on youTube.
https://t.me/tech_geek1

Interview Preparation Sheet:    • INTERVIEW PREPARATION SHEET - HASHEDIN and...  

Link for Leetcode solutions:    • Leetcode Solutions  

Link for placement series:
Placement 2022:    • Placements 2022  
Placement 2023:    • Placements 2023  

#leetcode #leetcodesolution