#C13299. Substring Starter Indices

    ID: 42821 Type: Default 1000ms 256MiB

Substring Starter Indices

Substring Starter Indices

You are given a list of strings and a target substring. Your task is to determine all indices (0-indexed) in the list where the string begins with the given target substring.

The input will provide the number of strings, followed by each string on a separate line, and finally the target substring on the last line. If the target substring is empty, the output should be an empty line.

For example, if the list is ["apple", "banana", "applet", "grape"] and the target is "app", the correct indices are 0 and 2 because "apple" and "applet" start with "app".

Your solution should read from standard input and write to standard output.

inputFormat

The input is given via standard input (stdin) with the following format:

  1. The first line contains an integer n, which represents the number of strings.
  2. The next n lines each contain a string.
  3. The last line contains the target substring.

Note: n can be 0, meaning there are no strings in the list.

outputFormat

Output a single line to standard output (stdout) containing the indices (0-indexed) of all strings in the list that start with the target substring. The indices should be separated by a single space. If there are no such indices, output an empty line.## sample

4
apple
banana
applet
grape
app
0 2

</p>