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. eclipse安装spring boot插件spring tool suite

    进行spring cloud的学习,要安装spring boot 的spring -tool-suite插件,我在第一次安装时,由于操作不当,两天才完全安装好,真的是要命了,感觉自己蠢死!下面就自己踩 ...

  2. BZOJ 1037: [ZJOI2008]生日聚会Party(区间dp)

    http://www.lydsy.com/JudgeOnline/problem.php?id=1037 题意: 思路: 四维数组进行dp,dp[i][j][a][b]表示进行到第i个座位时已经有j个 ...

  3. Go 结构体(Struct)

    引用曾经看到的一篇文章里面对 Golang 中结构体的描述,如果说 Golang 的基础类型是原子,那么 结构体就是分子.我们都知道分子是由原子组成的,换言之就是结构体里面可以包含基础类型.切片. 字 ...

  4. 在Idea创建Spring Boot + MyBatis的web项目

    创建步骤如下 选择Spring initializr  2. 修改group 与 atifact id,点击next 3. dependencies里面选择Web->Web , SQL -> ...

  5. 什么是 MIME TYPE?

    文章来源: http://baike.baidu.com/item/MIME https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Basics_of_H ...

  6. Windows android appium python3 环境搭建

    安装nodejs https://www.cnblogs.com/sea-stream/p/10520624.html java 环境变量配置: https://www.cnblogs.com/sea ...

  7. python函数名称

    一.第一类对象, 函数名的使用 函数名就是变量名, 函数名存储的是函数的内存地址 变量的命名规范: 由数字, 字母, 下划线组成 不能是数字开头, 更不能是纯数字 不能用关键字 不要太长 要有意义 不 ...

  8. CentOS6.5下安装配置MySQL数据库

    一.MySQL简介 说到数据库,我们大多想到的是关系型数据库,比如MySQL.Oracle.SQLServer等等,这些数据库软件在Windows上安装都非常的方便,在Linux上如果要安装数据库,咱 ...

  9. Mysql 强行Kill 连接

    BEGIN ; ; ; DO KILL @Temp; ; END WHILE ; END

  10. Java SE LinkedList的底层实现

    关于实现链表的底层原理 链表便于增删,不便于查询 package com.littlepage.linkedList; /** * 基于底层实现LinkedList * @author Littlep ...