Leetcode 131
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的更多相关文章
- leetcode@ [131/132] Palindrome Partitioning & Palindrome Partitioning II
https://leetcode.com/problems/palindrome-partitioning/ Given a string s, partition s such that every ...
- LeetCode 131. 分割回文串(Palindrome Partitioning)
131. 分割回文串 131. Palindrome Partitioning 题目描述 给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串. 返回 s 所有可能的分割方案. LeetC ...
- leetcode 131. Palindrome Partitioning 、132. Palindrome Partitioning II
131. Palindrome Partitioning substr使用的是坐标值,不使用.begin()..end()这种迭代器 使用dfs,类似于subsets的题,每次判断要不要加入这个数 s ...
- [LeetCode] 131. Palindrome Partitioning 回文分割
Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...
- Java实现 LeetCode 131 分割回文串
131. 分割回文串 给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串. 返回 s 所有可能的分割方案. 示例: 输入: "aab" 输出: [ ["aa ...
- Leetcode 131. Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...
- leetcode 131. Palindrome Partitioning----- java
Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...
- [leetcode]131. Palindrome Partitioning字符串分割成回文子串
Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...
- Java for LeetCode 131 Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome. Return all ...
随机推荐
- 【译】第23节---Fluent API - 实体映射
原文:http://www.entityframeworktutorial.net/code-first/configure-entity-mappings-using-fluent-api.aspx ...
- Js 运行机制 (重点!!)
一.引子 本文介绍JavaScript运行机制,这一部分比较抽象,我们先从一道面试题入手: 这一题看似很简单,但如果你不了解JavaScript运行机制,很容易就答错了.题目的答案是依次输出1 2 3 ...
- 使用ajax判断登录用户名
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Register.aspx. ...
- JqueryValidate 表单验证插件
1.适用场景 表单 ( 支持自定义规则 ) 2.相关文章 jQuery Validate 3.实际问题 JqueryValidate表单相同Name不校验问题解决
- AD10中创建材料清单(BOM表)
材料清单可以用来作为元件的采购清单,同时也可以用于查看PCB中的元件封装信息是否正确. 操作: Reports----->Bill of Materials
- CSS段落对齐方式
CSS段落对齐有两种方式:水平对齐和垂直对齐. 1.水平对齐: (1).text-align:left; //左对齐 (2).text-align:right; //右对齐 ...
- SQL左右连接中的on and和on where的区别
SQL左右连接中的on and和on where的区别 左联时,ON后面的对左边表的条件对左边表数据无影响(因为左连接符合左边所有条件),但对右边表数据有影响,只有符合左边表条件时,右边表数据才会查出 ...
- Java用FutureTask实现又返回值的线程
要实现有返回值的多线程,具体代码如下: package thread; import java.util.concurrent.Callable; import java.util.concurren ...
- Axure 元件的移动效果
元件的移动主要是指当点击某一元件(登录)时,某些元件会发生移动或者是左右移动的动画效果,先将登录界面设置为动态面板,然后再设置动作 本节主要应用于一下三种场景: 1.当邮箱不为空.密码为空时,点击登录 ...
- python+selenium:点击页面元素时报错:WebDriverException: Message: Element is not clickable at point (1372.5, 9.5). Other element would receive the click: <li style="display: list-item;" id="tuanbox"></li>
遇到一个非常郁闷的问题,终于解决了, 问题是这样的,NN网站的价格计划,每一个价格计划需要三连击才能全部点开,第一个房型的价格计划是可以正确三连击打开的,可是第二个房弄就不行了,报错说不是可点击的 ...