摘要: 在编程之美3.1中,此题解法是用strstr()函数,并且以空间换时间,其实只要用循环遍历即可其时间复杂度: k < O(n) < k+ n, 其中k为查找串的长度,n为数据串的长度,空间复杂度为O(1)。代码如下: 1 #include<iostream> 2 using namespace std; 3 4 int findSubStr(char source[], char subStr[], int sLen, int oLen) 5 { 6 if(source == NULL || subStr == NULL || sLen <=0 || oLen & 阅读全文
posted @ 2012-12-20 21:42 MichaelGD 阅读(185) 评论(0) 推荐(0) 编辑