正常是应该手写KMP算法 哈哈哈哈 一道题算一天 ,最后先搁置吧,看完kmp再写
代码:
class Solution { public: int strStr(string haystack, string needle) { return haystack.find(needle); } };
std::string::find函数
就是用于在字符串中查找子字符串,底层就是kmp算法。
正常是应该手写KMP算法 哈哈哈哈 一道题算一天 ,最后先搁置吧,看完kmp再写
代码:
class Solution { public: int strStr(string haystack, string needle) { return haystack.find(needle); } };
std::string::find函数
就是用于在字符串中查找子字符串,底层就是kmp算法。