Substrings With Concatenation Of All Words

easy
1. You are given a string, s, and a list of words, words, that are all of the same length. 2. 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. EXAMPLE Input: s = "barfoothefoobarman", words = ["foo","bar"] Output: [0,9] Explanation: Substrings starting at index 0 and 9 are "barfoor" and "foobar" respectively. The output order does not matter, returning [9,0] is fine too.

Input Format

First line contains N. Second line contains N space separated strings(words). Third line contains the string.

Output Format

Return an integer array(conaining indices)

Constraints

size of each string<100

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
2
foo bar
barfoothefoobarman
Output
[0, 9]
Previous
Meeting Rooms Ii
Next
Merge K Sorted Arrays

Related Questions