Solution:
# T:O(n) S:O(1) class Solution: # @param root, a tree node # @return nothing def connect(self, root): if root and root.left: root.left.next = root.right if root.next: root.right.next = root.next.left self.connect(root.left) self.connect(root.right)Run Time: 120 ms
No comments:
Post a Comment