又被python的pass by reference搞死
然後原本送第一版寫註解那樣 只贏5%
改成現在這樣就正常了
我還是不懂差在哪 姆咪
def partition(self, s: str) -> List[List[str]]:
ans = []
def dfs(idx, cur_list):
if idx == len(s):
ans.append(cur_list)
return
idx_r = idx
while idx_r<len(s):
if s[idx:idx_r+1] == s[idx:idx_r+1][::-1]:
# cur_list_next = copy.deepcopy(cur_list)
# cur_list_next.append(s[idx:idx_r+1])
# dfs(idx_r+1, cur_list_next)
dfs(idx_r+1, cur_list + [s[idx:idx_r+1]])
idx_r += 1
dfs(0,[])
return ans