#K13956. Find Substring Indices
Find Substring Indices
Find Substring Indices
Given a string \(s\) and a substring \(p\), find all starting indices in \(s\) where \(p\) is found. Occurrences may overlap. For example, if \(s = \texttt{abracadabra}\) and \(p = \texttt{abra}\), then the answer is \(0\) and \(7\). The goal is to identify all indices \(i\) (0-indexed) such that \(s[i : i+|p|] = p\). Use standard input (stdin) for reading input and standard output (stdout) for printing your results.
inputFormat
The input is given via standard input (stdin). It consists of two lines:
- The first line contains the string (s).
- The second line contains the substring (p).
outputFormat
Output to standard output (stdout) a space-separated list of all starting indices where (p) is found in (s). If no occurrence is found, output an empty line.## sample
abracadabra
abra
0 7