Simple python solution


  • 0
    F
    class Solution(object):
    def partition(self, s):
        res=[]
        self.cal(s,res,[])
        return res
    def cal(self, s, res, temp):
        if not s: res+=temp,
        for i in xrange(len(s)):if s[:i+1]==s[:i+1][::-1]: self.cal(s[i+1:], res, temp+[s[:i+1]])

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.