Invert Binary Tree
Created
February 23, 2021 22:51
-
-
Save GGrassiant/b422f88ee1908138aaeebe49c4c8f7ac to your computer and use it in GitHub Desktop.
Invert binary tree
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const InvertTree = (node) => { | |
| if (!node) { | |
| return; | |
| } | |
| [node.left, node.right] = [node.right, node.left]; | |
| InvertTree(node.left); | |
| InvertTree(node.right); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment