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

[Challenge] Invert Binary Tree #325

Open
drkennetz opened this issue Jul 13, 2022 · 3 comments
Open

[Challenge] Invert Binary Tree #325

drkennetz opened this issue Jul 13, 2022 · 3 comments
Labels
proposed challenge An idea for a future challenge

Comments

@drkennetz
Copy link
Collaborator

Invert Binary Tree

The classic algorithm problem that you see on all the coding interview prep advertisement sites! The challenge is simple: Write a function that takes in a Binary Tree and Inverts It. In other words, the function should swap every left node in the tree for its corresponding right node.

Each BinaryTree node has an integer value, a left child node, and a right child node. Children nodes can either be BinaryTree nodes themselves or None / null / nil.

Business Rules/Errata

  • The operation should modify the input tree - other objects should not be created to complete this challenge.

Examples

Sample Input

tree =        1
           /     \
         2        3
       /   \    /   \
      4     5  6     7
    /   \
   8     9

Sample Output

tree =        1
           /     \
          3       2
        /   \   /   \
       7     6 5     4
                   /   \
                  9     8
@drkennetz drkennetz added the proposed challenge An idea for a future challenge label Jul 13, 2022
@JulioCVaz
Copy link
Contributor

JulioCVaz commented Oct 26, 2022

Hi, this challenge makes part of hacktoberfest? @drkennetz

@drkennetz
Copy link
Collaborator Author

@JulioCVaz this one hasn't been implemented yet, but if you solve any challenge we've already posted under the "challenges" folder, we'll accept them with the hacktoberfest-accepted label and they'll count. You either have to solve the challenge in a new language, or find a different solution than one that has already been posted.

@JulioCVaz
Copy link
Contributor

@drkennetz nice! I'll participate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposed challenge An idea for a future challenge
Projects
None yet
Development

No branches or pull requests

2 participants