leetcode 30. Substring with Concatenation of All Words
来源:互联网 发布:做电子相册的软件 编辑:程序博客网 时间:2024/06/05 17:50
一个简单的通过next_permutation来进行字符串查找的函数,很遗憾,超时
vector<int> findSubstring(string s, vector<string>& words) {vector<int> order;vector<int> ret;for(int i=0;i<words.size();i++)order.push_back(i);string _s = s;do{ string subStr = ""; _s = s; for(int i=0;i<order.size();i++)subStr += words[order[i]]; int tmp = _s.find(subStr); int pre = 0; while(tmp!=-1){ ret.push_back(pre+tmp); tmp++; pre+=tmp; while(tmp--)_s.erase(_s.begin()); tmp = _s.find(subStr); }}while(next_permutation(order.begin(),order.end()));sort(ret.begin(),ret.end());vector<int>::iterator iter = unique(ret.begin(),ret.end());ret.erase(iter,ret.end());}
0 0
- 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
- [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
- 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
- Leetcode: Substring with Concatenation of All Words
- leetcode:Substring with Concatenation of All Words
- LeetCode|Substring with Concatenation of All Words
- Error:warning: Ignoring InnerClasses attribute for an anonymous inner class
- 如何排版 微信公众号「代码块」
- android开发解决方法数量超过65536的说明
- windows 下架设svn服务器(转载)
- 【bzoj1031】[JSOI2007]字符加密Cipher
- leetcode 30. Substring with Concatenation of All Words
- 安卓中横竖屏切换和Activity的生命周期的处理
- 查询当前一周的数据,查询本周剩余日期的数据
- springmvc Aspect 实现自定义注解的日志记录
- php禁止直接从浏览器输入地址访问.php文件的方法
- Hadoop源码分析之一(RPC机制之Server)
- Android线程中消息处理(Handle,Looper)
- Gradle在大型Java项目上的应用
- Java覆盖中应该注意的地方