Untitled
def func(root): if root.left is None and root.right is None: return [str(root.value)] return [i + str(root.value) for i in func(root.left)] + [i + str(root.value) for i in func(root.right)] def solve(root): paths = sum(int(i[::-1], 2) for i in func(root)) return paths
Leave a Comment