Substring with Concatenation of All Words
来源:互联网 发布:形容男人帅的网络词 编辑:程序博客网 时间:2024/05/16 15:25
#include <stdio.h>#include <stdlib.h>#include <unistd.h>#include <stdint.h>#include <sys/wait.h>#include <limits.h>#include <time.h>#include <pthread.h>#include <string.h>#include <iostream>#include <vector>#include <queue>#include <sstream>#include <iterator>#include <algorithm>#include <thread>using namespace std;vector<int> &findSubstring(const string &s, vector<string>&words) {int i;string line;static vector<int>indices;vector<int>tmpvec;
indices.clear();if(s.empty()) {cerr << "s is none...!" << endl;return indices;}int size = words.size();if(!size) {cerr << "words is none...!" << endl;return indices;}tmpvec.resize(size);for(i = 0;i < size;i++) tmpvec[i] = i;do{// join the words to lineline.clear();for(i = 0;i < size;i++){int index = tmpvec[i];line += words[index];}// find line in the s{int pos = s.find(line, 0);if(pos == string::npos) continue;int len = line.size();do{indices.push_back(pos);pos = s.find(line, pos + len);}while(pos != string::npos);}}while(next_permutation(tmpvec.begin(), tmpvec.end()));return indices;}int main() {string s = "barfoofoobarthefoobarman";vector<string>words;words.push_back("bar");words.push_back("foo");words.push_back("the");vector<int>&rs = findSubstring(s, words);copy(rs.begin(), rs.end(), ostream_iterator<int>(cout, " "));cout << endl;return 0;}CC=g++all:$(CC) -std=c++11 -g -o hello helloC++.cpp -pthread -lpthread
0 0
- LeetCode: Substring with Concatenation of All Words
- LeetCode : Substring with Concatenation of All Words
- LeetCode29: Substring with Concatenation of All Words
- [Leetcode] Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- [LeetCode]Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- LeetCode-Substring with Concatenation of All Words
- [LeetCode] Substring with Concatenation of All Words
- 26 - Substring with Concatenation of All Words
- LeetCode:Substring with Concatenation of All Words
- Leetcode: Substring with Concatenation of All Words
- [LeetCode] Substring with Concatenation of All Words
- leetcode Substring with Concatenation of All Words
- leetcode Substring with Concatenation of All Words
- Substring with Concatenation of All Words
- LeetCode Substring with Concatenation of All Words
- 程序员面试金典: 9.11 排序与查找 11.1给定两个排序后的数组A和B,其中A的末端有足够的缓冲容纳B。编写一个方法,将B合入A并排序。
- 函数
- 无参考图像质量评价之基于多特征的增强图像质量评价
- 图像特征提取三大法宝:HOG特征,LBP特征,Haar特征
- 求数字在数组中出现的次数
- Substring with Concatenation of All Words
- 表单form action的url写法
- 72问72答 — 小程序集合(非研发级问答)
- Qemu运行linux 4.9
- 程序员面试金典: 9.11 排序与查找 11.1编写一个方法,对字符串数组进行排序,将所有变位词排在相邻的位置。
- 小程序模仿QQ6.0侧滑菜单
- 最小二乘
- 飞机大战
- 【已解决】web项目中新加的jar包和tomcat自带的jar冲突问题