https://leetcode.com/problems/implement-strstr/
Implement strStr().
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
public int StrStr(string haystack, string needle)
{
int n1 = haystack.Length;
int n2 = needle.Length;
if (n2 == 0)
return 0;
for (int i = 0; i <= n1-n2; i++)
{
if (haystack[i] == needle[0])
{
int j = 0;
while (j<n2&&haystack[i + j] == needle[j])
j++;
if (j == n2)
return i;
}
}
return -1;
}