Untitled

mail@pastecode.io avatar
unknown
plain_text
10 months ago
293 B
1
Indexable
Never
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