Concise Python Solution


  • 0
    L
    def pathSum(self, root, sum):
        if not root:
            return []
            
        if not root.right and not root.left:
            return [[root.val]] if root.val == sum else []
    
        return [[root.val]+i for i in self.pathSum(root.left,sum-root.val) + self.pathSum(root.right,sum-root.val)]

Log in to reply
 

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