标签:
117 Populating Next Right Pointers in Each Node II
就是 Bibary Tree Level order Traverse
class Solution: # @param root, a tree link node # @return nothing def connect(self, root): if root == None: return q, pre = [root, None], None while True: node = q.pop(0) if node != None: if pre != None: pre.next = node pre = node if node.left != None: q.append(node.left) if node.right != None: q.append(node.right) else: if q == []: break else: q.append(None) pre = None
117 Populating Next Right Pointers in Each Node II
标签:
原文地址:http://www.cnblogs.com/dapanshe/p/4669160.html