class Solution {
public:
int strStr(string haystack, string needle) {
int n = haystack.size(), L = needle.size();
for (int i = 0;i < n - L + 1;i++)
{
if (haystack.substr(i, L) == needle)
{
return i;
}
}
return -1;
}
};
LeetCode28. 实现 strStr()
最新推荐文章于 2022-02-23 21:24:37 发布