Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

116. Populating Next Right Pointers in Each Node #99

Open
tech-cow opened this issue Mar 19, 2020 · 0 comments
Open

116. Populating Next Right Pointers in Each Node #99

tech-cow opened this issue Mar 19, 2020 · 0 comments
Projects

Comments

@tech-cow
Copy link
Owner

116 | Populating Next Right Pointers in Each Node

BFS Solution

class Solution(object):
    def connect(self, root):
        if not root:
            return 
        queue = [root]
        while queue:
            curr = queue.pop(0)
            if curr.left and curr.right:
                curr.left.next = curr.right
                if curr.next:
                    curr.right.next = curr.next.left
                queue.append(curr.left)
                queue.append(curr.right)

image


image

@tech-cow tech-cow created this issue from a note in Facebook (重刷) Mar 19, 2020
@tech-cow tech-cow moved this from Redo to To-Do in Facebook Apr 28, 2020
@tech-cow tech-cow moved this from To-Do to Redo in Facebook Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Facebook
  
Redo
Development

No branches or pull requests

1 participant