Exemplo n.º 1
0
def connect(root):
    for level in iter_level([root]):
        for a, b in izip(level, level[1:] + [None]):
            a.next = b
Exemplo n.º 2
0
def zigzagLevelOrder(root):
    return [[node.val for node in v[::s]]
            for v, s in zip(iter_level([root]), zigzag())]
def levelOrder(root):
    return [[node.val for node in nodes]
            for nodes in iter_level([root])]
def levelOrder(root):
    return [[node.val for node in nodes] for nodes in iter_level([root])]
Exemplo n.º 5
0
def levelOrderBottom(root):
    return [[node.val for node in nodes] for nodes in iter_level([root])][::-1]
def levelOrderBottom(root):
    return [[node.val for node in nodes]
            for nodes in iter_level([root])][::-1]