Short python solution. But still slow?


  • 0
    T
    def connect(self, root):
        if not root: return
        left = root.left
        right = root.right
        self.connect(left)
        self.connect(right)
        while left:
            left.next = right
            left = left.right
            right = right.left
    

    The running time is 123ms. Home come?


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.