leetcode131 分割回文串 python
2019-04-20 10:38
776 查看
分割回文串(中等)(leetcode131)
给一个字符串s,将s分割成一些子串,使每个子串都是回文串,返回 s 所有可能的分割方案。
示例: 输入: "aab" 输出:
[
["aa","b"],
["a","a","b"]
]
def partition(self, s):
res=[]
if(s==''):
return []
if(s==s[::-1]):
res.append([s])
for i in range(len(s)):
if(s[:i+1]==s[i::-1]):
ss=self.partition(s[i+1:])
for c in ss:
if(c!=[]):
res.append([s[:i+1]]+c)
return res
相关文章推荐
- 利用python 完成 leetcode131 分割回文串
- [和小菜鸡一起刷题(python)] LeetCode 132. 分割回文串 II (Palindrome Partitioning II)
- 利用python 完成 leetcode132 分割回文串 II
- leetcode131.分割回文串
- 【LeetCode】#131分割回文串(Palindrome Partitioning)
- LeetCode:分割回文串(Python版本)
- [和小菜鸡一起刷题(python)] LeetCode 131. 分割回文串 (Palindrome Partitioning)
- LeetCode-----回文串的最小分割
- LeetCode-Python-409. 最长回文串
- Python解LeetCode 131: Palindrome Partitioning(Python中的浅复制与深复制)
- [LeetCode 131] - 回文分割(Palindrome Partitioning)
- Python LeetCode(125.验证回文串)
- LeetCode 高级 - 分割回文串
- Leetcode分割回文串
- leetcode-最长回文串(python)
- 高频算法面试题(字符串) leetcode 131. 分割回文串
- [LeetCode]题解(python):131-Palindrome Partitioning
- LeetCode:131 分隔回文串——我想到的一种又慢又复杂的迷之方法
- 【LeetCode】分割回文串
- LeetCode-Python-410. 分割数组的最大值