class Solution:
    def partition(self, s: str) -> List[List[str]]:
        # time O(N*2^N) space O(N) for path 
        """
        step1, initialize the res, and path 
        step2, dfs, retrive a substring end from 1(be careful the slicing exclusive),loop the whole string  
        step3, check if substring parlindrom, if yes, add substring to path. do recursion based on string after the substring ; then revoke current add substring operation, increase substring length 
        step4, terminate until target string s is empty, add path to res(using deep copy)
        """
        res = []
        def btr(s,path):
            if s == "" :
                res.append(path[:]) # pass with deep copy 
                return res
            # end of substring  s[:end]
            for end in range(1,len(s)+1): # be aware of boundry 
                sub = s[:end]
                print(sub)
                if is_palindrom(sub):
                    path.append(sub)
                    btr(s[end:],path)
                    path.pop()
                    
        def is_palindrom(s):
            return s == s[::-1]
        btr(s,[])
        return res