摘要: 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 阅读全文
posted @ 2013-06-20 01:52 一只会思考的猪 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2013-06-20 01:49 一只会思考的猪 阅读(214) 评论(0) 推荐(0) 编辑