Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def is_palindrome(s):
- if s[:]==s[::-1]:
- return True
- return False
- def fun(i,s,cur,ans):
- if i==len(s):
- ans.append(cur)
- for end in range(i+1,len(s)+1):
- if is_palindrome(s[i:end]):
- fun(end,s,cur+[s[i:end]],ans)
- class Solution:
- def partition(self, s: str) -> List[List[str]]:
- ans=[]
- fun(0,s,[],ans)
- return ans
Advertisement
Add Comment
Please, Sign In to add comment