![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
string
拥抱新生活
怀揣着对未来世界美好的憧憬,从容燃烧
展开
-
string KMP算法理解
int KMP_find(string s, string pattren,int begin=0) //begin表示开始下标 { vectornext = KMP_next(pattren); //得到next数组 int i = begin; int j = 0; while (i < s.size()&&j<pattren.size()) { while (原创 2016-10-17 15:34:58 · 294 阅读 · 0 评论 -
leetcode: Find All Anagrams in a String
class Solution {public: vector<int> KMP_next(string match) { vector<int>next(match.size()); next[0] = -1; int j = 0, k = -1; while (j<match.size() - 1)原创 2016-10-28 10:59:16 · 239 阅读 · 0 评论 -
leetcode:string hard系列三:word break
https://leetcode.com/problems/word-break/https://leetcode.com/problems/word-break-ii/class Solution {public: vector wordBreak(string s, unordered_set& wordDict) { vector原创 2016-10-18 22:30:27 · 365 阅读 · 0 评论 -
复杂情况下string翻转
把一个句子以单词为最小单位的翻转 考察点在于:在原来句子中,可能存在任意插入的空格,预处理删除这些空格代码class Solution {public: void reverseWords(string &s) { tackleSpace(s); reverse(s.begin(), s.end()); //整体翻转 int index原创 2016-10-20 21:10:00 · 183 阅读 · 0 评论