摘要: 字符串匹配,实现c++ strstr()函数 1.蛮力法 2.Robin Karp 具体说明参考维基百科:https://en.wikipedia.org/wiki/Rabin–Karp_algorithm 3.kmp 具体说明参考维基百科:https://en.wikipedia.org/wiki 阅读全文
posted @ 2016-08-10 23:26 zhangbaochong 阅读(5605) 评论(0) 推荐(0) 编辑
摘要: 题目:字符串匹配 Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 分类:String Two P 阅读全文
posted @ 2016-08-10 23:19 zhangbaochong 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 原文地址:https://www.byvoid.com/blog/string-hash-compare 常用的字符串Hash函数还有ELFHash,APHash等等,都是十分简单有效的方法。这些函数使用位运算使得每一个字符都对最后的函数值产生影响。另外还有以MD5和SHA1为代表的杂凑函数,这些函 阅读全文
posted @ 2016-08-10 17:53 zhangbaochong 阅读(827) 评论(0) 推荐(0) 编辑
摘要: 题目: Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example,"A man, a plan, a canal: 阅读全文
posted @ 2016-08-10 16:48 zhangbaochong 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 题目: Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0. You may a 阅读全文
posted @ 2016-08-10 16:29 zhangbaochong 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 由于c++字符串没有split函数,所以字符串分割单词的时候必须自己手写,也相当于自己实现一个split函数吧! 如果需要根据单一字符分割单词,直接用getline读取就好了,很简单 如果是多种字符分割,比如,。!等等,就需要自己写一个类似于split的函数了: 例如:输入hello world!W 阅读全文
posted @ 2016-08-10 01:15 zhangbaochong 阅读(7667) 评论(2) 推荐(1) 编辑