Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution:
- def ispalindrome(self, s, start,end):
- while(start < end):
- if (s[start] != s[end]):
- return False
- start +=1
- end -=1
- return True
- def helper(self, s, result, start, currentlist):
- if start >= len(s):
- result.append(currentlist[:])
- end=start
- while end<len(s):
- if (self.ispalindrome(s, start,end)):
- currentlist.append(s[start:end+1])
- self.helper( s, result, end+1, currentlist)
- currentlist.pop()
- end+=1
- def partition(self, s: str) -> List[List[str]]:
- result = []
- currentlist=[]
- self.helper(s, result, 0, currentlist)
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement