#K40932. Find Substring
Find Substring
Find Substring
Given two strings s and p, determine the starting index of the first occurrence of p in s. If p is not found in s, output -1
.
In particular, if p is an empty string, by definition, the answer is 0
.
Formally, find the smallest index \( i \) such that \( s[i:i+\text{len}(p)] = p \).
inputFormat
The input consists of two lines:
- The first line contains the string s.
- The second line contains the string p.
outputFormat
Output a single line containing the index of the first occurrence of p in s. If p does not occur in s, output -1
.
hello
ll
2