摘要:
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.思路:朴素算法和KMP,此外还有Karbin-ship算法。关于next的数组,只需要知道一点:求patten串i位置(包括自己)最大前缀子串的长度,这个长度其实就是将来i+1的位置失配之后,下一次j重新比较的位置。也可以理解为一个dp的过程#include <iostream>#include <string.h>#incl 阅读全文
摘要:
Implement wildcard pattern matching with support for'?'and'*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire input string (not partial).The function prototype should be:bool i 阅读全文