- class Solution:
- def partition(self, s: str) -> List[List[str]]:
- res=[]
- path=[]
- def f(index):
- if index==len(s):
- res.append(path[:])
- return
- for i in range(index,len(s)):
- temp=s[index:i+1]
- if temp==temp[::-1]:
- path.append(temp)
- f(i+1)
- path.pop()
- f(0)
- return res