[LeetCode]Generalized Abbreviation
来源:互联网 发布:淘宝快捷支付怎么开通 编辑:程序博客网 时间:2024/05/18 03:33
</pre><pre code_snippet_id="1619282" snippet_file_name="blog_20160322_2_769678" name="code" class="cpp">class SolutionTest {public:vector<string> res;vector<string> generateAbbreviations(string word) {if(word.size()==0) return res;dfs(word,"",0);return res;}void dfs(string& s,string cur,int start) {if(start==s.size()) {res.push_back(cur);cout<<cur<<endl;return;}if(start==0) {for(int j=1;j<=s.size();j++) {stringstream ss;ss<<j;dfs(s,ss.str(),j);}}for(int i=start;i<s.size()-1;i++) {for(int j=i+1;j<s.size();j++) {string tmp=s.substr(start,i-start+1);stringstream ss;ss<<(j-i);dfs(s,cur+tmp+ss.str(),j+1);}}cout<<"hi: "<<cur+s.substr(start)<<endl;res.push_back(cur+s.substr(start));}};
0 0
- Leetcode: Generalized Abbreviation
- [LeetCode]Generalized Abbreviation
- leetcode Generalized Abbreviation
- LeetCode 320. Generalized Abbreviation
- Leetcode 320. Generalized Abbreviation
- Generalized Abbreviation
- Generalized Abbreviation
- [leetcode] 320. Generalized Abbreviation 解题报告
- LeetCode 320. Generalized Abbreviation(产生缩写)
- [Leetcode] 320. Generalized Abbreviation 解题报告
- [leetcode320]Generalized Abbreviation
- 320. Generalized Abbreviation
- 320. Generalized Abbreviation
- *LeetCode-Unique Word Abbreviation
- Leetcode Unique Word Abbreviation
- leetcode 288: Unique Word Abbreviation
- [leetcode 288] Unique Word Abbreviation
- LeetCode 256. Unique Word Abbreviation
- 分库
- javascript心得随记
- 此博客主要用来记录自己从他人学习到的东西
- 输入一个链表,输出该链表中倒数第k个结点。
- poj 3111 K Best
- [LeetCode]Generalized Abbreviation
- android 中遥控器键值的添加和修改
- Android异常java.lang.IllegalStateException: The specified child already has a parent.
- 《从零开始学Swift》学习笔记(Day 63)——Cocoa Touch设计模式及应用之单例模式
- ES2015 - Array (4)
- mysql审计插件(运维不在背锅)
- C语言单链表——之常见面试题目2
- 三种多线程简介及使用方法
- JVM的垃圾收集机制和内存分配策略