class Solution {
public:
vector<vector<string>> partition(string s) {
vector<string> add;
vector<vector<string>> res;
dfs(res,add,s,);
return res;
}
void dfs(vector<vector<string>>& res,vector<string> add,string s,int start){
if(start == s.size()){
res.push_back(add);
}
else{
for(int i=start;i < s.size();i++){
if(ishui(s,start,i)){
add.push_back(s.substr(start,i-start+)); //子串的写法
dfs(res,add,s,i+);
add.pop_back();
}
}
}
} bool ishui(string s,int start,int end){
while(start <= end){
if(s[start] != s[end]) return false;
start++;end--;
}
return true;
}
};

_

Leetcode 131的更多相关文章

  1. leetcode@ [131/132] Palindrome Partitioning & Palindrome Partitioning II

    https://leetcode.com/problems/palindrome-partitioning/ Given a string s, partition s such that every ...

  2. LeetCode 131. 分割回文串(Palindrome Partitioning)

    131. 分割回文串 131. Palindrome Partitioning 题目描述 给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串. 返回 s 所有可能的分割方案. LeetC ...

  3. leetcode 131. Palindrome Partitioning 、132. Palindrome Partitioning II

    131. Palindrome Partitioning substr使用的是坐标值,不使用.begin()..end()这种迭代器 使用dfs,类似于subsets的题,每次判断要不要加入这个数 s ...

  4. [LeetCode] 131. Palindrome Partitioning 回文分割

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...

  5. Java实现 LeetCode 131 分割回文串

    131. 分割回文串 给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串. 返回 s 所有可能的分割方案. 示例: 输入: "aab" 输出: [ ["aa ...

  6. Leetcode 131. Palindrome Partitioning

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...

  7. leetcode 131. Palindrome Partitioning----- java

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...

  8. [leetcode]131. Palindrome Partitioning字符串分割成回文子串

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...

  9. Java for LeetCode 131 Palindrome Partitioning

    Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...

随机推荐

  1. 重写NLog

    接口ILogBase: public interface ILogBase { void Debug(string message); void Debug(string message, Excep ...

  2. C# 获取程序运行目录

    string a = "BaseDirectory:" + AppDomain.CurrentDomain.BaseDirectory + "\r\n" + & ...

  3. 【BZOJ】4542: [Hnoi2016]大数

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=4542 给定一个由数字构成的字符串${S_{1,2,3,...,n}}$,一个正素数$P$, ...

  4. django信号 signal

    django自带一套信号机制来帮助我们在框架的不同位置之间传递信息.也就是说,当某一事件发生时,信号系统可以允许一个或多个发送者(senders)将通知或信号(signals)发送给一组接受者(rec ...

  5. VC静态调用DLL(lib)

    1. #pragma comment(lib, "libxml2.lib")#pragma comment(lib, "iconv.lib")#pragma c ...

  6. ArrayList list = new ArrayList()在这个泛型为Integer的ArrayList中存放一个String类型的对象

    java面试要点---ArrayList list = new ArrayList(); 在这个泛型为Integer的ArrayList中存放一个String类型的对象. ArrayList list ...

  7. Discrete Log Algorithms :Baby-step giant-step

    离散对数的求解 1.暴力 2.Baby-step giant-step 3.Pollard’s ρ algorithm …… 下面搬运一下Baby-step giant-step 的做法 这是在 ht ...

  8. HTML5语义化

    转载自:https://www.cnblogs.com/fliu/articles/5244866.html 1.什么是HTML语义化? 用合理.正确的标签来展示内容,比如h1~h6定义标题,便于开发 ...

  9. Python 新建程序

    1.建立一个新的文件夹 2.建一个包 3.建一个程序项目 4.默认模板配置

  10. springboot之启动方式

    我们在ideal中启动springboot项目时时不需要加载Tomcat容器的,直接在启动类启动就行了,原因是springboot项目中默认包含了内置Tomcat //springboot项目必须引入 ...