被搜索的字符串称为主串,待搜索的字符串称为模式串。朴素模式匹配算法的基本思想:
对主串的每一个字符作为子串开头,与模式串进行匹配。对主串做大循环,每个字符开头做模式串长度的小循环,直到匹配成功或全部遍历完成为止。
代码实现非常简单:
int strStr(char *haystack, char *needle) {
for (int i = 0;...
分类:
编程语言 时间:
2015-02-03 15:12:54
阅读次数:
224
原文来自于:http://www.infoq.com/cn/articles/etcd-interpretation-application-scenario-implement-principle随着CoreOS和Kubernetes等项目在开源社区日益火热,它们项目中都用到的etcd组件作为一个...
分类:
其他好文 时间:
2015-02-03 14:35:26
阅读次数:
293
Given an array of integers, every element appears three timesexcept for one. Find that single one.
Note:
Your algorithm should have a linear runtime complexity. Could you implement itwithout using e...
分类:
编程语言 时间:
2015-02-02 23:15:12
阅读次数:
248
题目链接:Implement strStr()
Implement strStr().
Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
Update (2014-11-02):
The signature of the func...
分类:
其他好文 时间:
2015-02-02 12:31:43
阅读次数:
135
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.字符串匹配问题,要注意needle 为空的情况,最简...
分类:
其他好文 时间:
2015-02-02 12:30:35
阅读次数:
97
题目描述:Implement regular expression matching with support for'.'and'*'.'.' Matches any single character.'*' Matches zero or more of the preceding elemen...
分类:
其他好文 时间:
2015-02-02 10:45:29
阅读次数:
187
Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the valu...
分类:
系统相关 时间:
2015-01-31 17:43:36
阅读次数:
158
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com'31: Next Permutationhttps://oj.leetcode.com/problems/next-permutation/Implement next permu...
分类:
编程语言 时间:
2015-01-31 07:01:44
阅读次数:
180
题目Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the va...
分类:
系统相关 时间:
2015-01-30 17:19:54
阅读次数:
162
Why to use memory pool and how to implement itIntroduce memory poolDownload MemoryPoolSourceCode.zip - 21.82 KB IntroductionWhat is memory pool? I thi...
分类:
其他好文 时间:
2015-01-30 17:04:37
阅读次数:
166