You are given two strings: text and pattern.
Return the index of the first place pattern appears in text.
If pattern does not appear, return -1.
Input: text = "hellohello", pattern = "llo"
Output: 2
Explanation:
"llo" first appears starting at index 2.
Input: text = "openai", pattern = "ai"
Output: 4
Explanation:
"ai" appears first at index 4.
Input: text = "python", pattern = "java"
Output: -1
Explanation:
java" is not in "python".
Accepted:
Submission: