Simple solution in python3


#1
def pathSum(self, A, B):
    self.value ,self.lis = 0,list()
    self.fl = []
    foo(A,B,self.value,self.lis,self.fl)
    return self.fl

def foo(A,B,value,lis,fl):

if A == None:
    return 0
#value = value + A.val
lis.append(A.val)
value = value + A.val

if value == B and A.left == None and A.right == None :
    #print(lis)
    fl.append(lis[:])

foo(A.left,B,value,lis,fl)

foo(A.right,B,value,lis,fl)

x = lis.pop()
value = value - x

#2

what is differenve between fl.append(lis[:]) and fl.append(lis)


#3

lis[:] create a copy of the list whereas lis just points at that memory