#C13692. Find Substring Indices
Find Substring Indices
Find Substring Indices
You are given two strings, s and t. Your task is to find all starting indices in s where the substring t occurs.
Indices are 0-indexed. Print all indices in ascending order separated by a single space. If t does not occur in s, print an empty line.
Mathematically, given a string \( s \) of length \( n \) and a substring \( t \) of length \( m \), you need to output all indices \( i \) (with \( 0 \leq i \leq n-m \)) such that \[ s[i:i+m] = t. \]
inputFormat
The input consists of two lines:
- The first line contains the string s.
- The second line contains the string t.
outputFormat
Output a single line containing all starting indices where the substring t is found in s. The indices must be printed in ascending order separated by a space. If no occurrence is found, output an empty line.
## sampleabracadabra
abra
0 7