#K84887. Implement strStr Function

    ID: 36519 Type: Default 1000ms 256MiB

Implement strStr Function

Implement strStr Function

Given two strings, (\textit{haystack}) and (\textit{needle}), implement a function that returns the index of the first occurrence of (\textit{needle}) in (\textit{haystack}), or (-1) if (\textit{needle}) is not a substring of (\textit{haystack}). The comparison is case-sensitive. Use built-in methods when available to ensure efficiency.

inputFormat

The input consists of two lines. The first line contains the string (\textit{haystack}). The second line contains the string (\textit{needle}). Note that (\textit{needle}) may be empty.

outputFormat

Output a single integer representing the index of the first occurrence of (\textit{needle}) in (\textit{haystack}). If (\textit{needle}) is not found, output (-1).## sample

hello
ll
2