Lintcode 680. split string(分割字符串)(更改后)
来源:互联网 发布:网络唤醒数据包 编辑:程序博客网 时间:2024/06/10 08:39
给一个字符串,你可以选择在一个字符或两个相邻字符之后拆分字符串,使字符串由仅一个字符或两个字符组成,输出所有可能的结果
样例
给一个字符串"123"
返回[["1","2","3"],["12","3"],["1","23"]]
标签
最近博客一直打不开,粘上来,睡觉。。
class Solution {public: /* * @param : a string to be split * @return: all possible split string array */ vector<vector<string>> splitString(string s) { // write your code here vector<string> temp; vector<vector<string>> result; int length=s.length(); splitStringHelper(0,s,temp,result); return result; } void splitStringHelper(int start,string& s,vector<string> temp,vector<vector<string>>& result) { if(start>=s.length()) { result.push_back(temp); return; } vector<string> tmp=temp; tmp.push_back(s.substr(start,1)); splitStringHelper(start+1,s,tmp,result); if(start+2<=s.length()){ //temp.erase(temp.end()); temp.push_back(s.substr(start,2)); splitStringHelper(start+2,s,temp,result); } } };
阅读全文
0 0
- Lintcode 680. split string(分割字符串)(更改后)
- String.split() 字符串分割
- 字符串分割(split 方法)
- Matlab---------字符串分割(split)
- Java字符串分割(split)
- Android 字符串分割split()
- 字符串操作(分割:split)
- split分割字符串(按两种符号分割)
- String split分割字符串问题
- Lua string split分割字符串
- C# string.split 分割字符串
- c++ string split分割字符串
- c++ string split分割字符串
- string进阶字符串分割String.Split
- 用Matlab实现字符串分割(split)
- C#字符串的分割(Split)
- C#分割(Split)字符串问题
- 用Matlab实现字符串分割(split)
- 一周二次课(10月17日)
- 互联网金融
- Android Socket通信详解
- 战场,紫书P175UVa11853
- 从键盘输入20个数a1到a20,计算并输出b1到b10,b1=根号(a1*a1+a20*a20),...,b10=根号(a10*a10+a11*a11)
- Lintcode 680. split string(分割字符串)(更改后)
- 项目中自动读取properties文件
- C++虚函数机制解析
- 3.3.1ThreadLocal各线程变量的隔离
- 软件测试十本书
- 微信小程序开发之天气预报
- linux克隆虚拟机出现问题bringing up interface eth0:device eth0
- python中模拟switch
- hdu5730 Shell Necklace