python O(1) solution, no count

  • 0
    class Solution:
        # @param root, a tree link node
        # @return nothing
        def connect(self, root):
            if not root:
            leftfix = root
            while leftfix.left:
                uppermover = leftfix
                lowermover = TreeLinkNode(0)
                while uppermover:
           = uppermover.left
                    lowermover =
           = uppermover.right
                    lowermover =
                    uppermover =
                leftfix = leftfix.left

Log in to reply

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