Path Sums
def f(r, s):
if not r:
return
if not r.left and not r.right: # leaf
path_sums.append(s)
return
if r.left:
helper(r.left, s + r.left.val)
if r.right:
helper(r.right, s + r.right.val)Last updated