双指针:c++「朴素匹配」而言,一旦匹配失败,将会将原串指针调整至下一个「发起点」,匹配串的指针调整至起始位置,然后重新尝试匹配。「朴素匹配」的复杂度是O(m*n)class Solution {public: int strStr(string haystack, string needle) { for(int i = 0; i + needle.size() <= haystack.size(); i++) { int j = 0;.
leetcode
2023-09-20
152 点赞
2 评论
230 浏览