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. Unity3D学习笔记(二十八):Editor

    Editor: 对编辑器进行一些拓展开发 关于继承Mono类的扩展开发   特性: [特性]:声明性的标签(类,方法,结构体,变量) 特性只对字段声明有效,后面必须接字段:多个特性,可以修饰一个字段 ...

  2. 【.NET开发之美】使用ComponentOne提高.NET DataMap中的加载速度

    概述 FlexGrid for WinForm 采用了最新的数据绑定技术,并与Microsoft .NET Framework无缝集成. 因此,您可以获得易于使用的灵活网格控件,用于创建用户友好界面, ...

  3. 解决Linux服务器磁盘空间不足的问题

    在linux服务器执行程序时报错: awk: write failure (No space left on device)awk: close failed on file /dev/stdout ...

  4. -第3章 jQuery方法实现下拉菜单显示和隐藏

    知识点 jquery 的引入方式 本地下载引入 在线引入 children 只获取子元素,不获取孙元素 show() 显示. hide() 隐藏. 完整代码 <!-- Author: XiaoW ...

  5. OpenLayers中的球面墨卡托投影

    最近看OpenLayers,研究到地图投影时找到官方的文档,就翻译了一下,由于英文能力差,翻译不好的地方,请看原文 原文地址:http://docs.openlayers.org/library/sp ...

  6. Python cmd中输入'pip' 不是内部或外部命令,也不是可运行的程序或批处理文件。

    配置一下环境变量,找到 添加一下Scripts文件夹的路径,如:这是我的路径C:\Users\ck\AppData\Local\Programs\Python\Python36 就是你python的安 ...

  7. _event_phase_team

    EventId 事件ID Phase 阶段ID,从1开始 TeamId 事件玩家分组,攻守(防守为1,进攻为2),自定义阵营(_faction表自定义阵营ID),公会(公会guid) Graveyar ...

  8. win 10 安装visual studio 2010

    链接: https://pan.baidu.com/s/1JzA2Ei8NEGRPck253NUM9g 提取码: 52pt 点击下一步即可.

  9. python tcp .demo

    client: # -*- coding: utf- -*- import socket s=socket.socket(socket.AF_INET,socket.SOCK_STREAM) s.co ...

  10. linux df

    显示磁盘使用情况 [hadoopuser@CNSZ443239 ~]$ df   文件系统                            1K-块           已用      可用 已 ...