wcsstr method
Finds the first occurrence of the wide substring needle in the wide string haystack.
Returns the index of the substring, or -1 if the substring is not found.
Implementation
int wcsstr(List<wchar_t> haystack, List<wchar_t> needle) {
if (needle.isEmpty) return 0;
for (int i = 0; i <= haystack.length - needle.length; i++) {
bool match = true;
for (int j = 0; j < needle.length; j++) {
if (haystack[i + j] != needle[j]) {
match = false;
break;
}
}
if (match) return i;
}
return -1;
}