2018-11-19 leetcode Palindrome Partitioning Palindrome PartitioningDFS Version - 192ms 1234567891011121314151617181920class Solution: def partition(self, s): """ :type s: str :rtype: List[List[str]] """ res = [] self.dfs(s, [], res) return res def dfs(self, s, path, res): if not s: res.append(path) return for i in range(1, len(s) + 1): if self.is_palindrome(s[:i]): self.dfs(s[i:], path + [s[:i]], res) def is_palindrome(self, s): return s == s[::-1] test code 12In [10]: s = Solution(); t = s.partition("aab"); print(t)[['a', 'a', 'b'], ['aa', 'b']] leet code Newer Set Matrix Zeroes Older Longest Increasing Path in a Matrix