Created
June 9, 2018 08:22
-
-
Save youngdo212/a94a15d7029c2a03fdfeb693482e25dd to your computer and use it in GitHub Desktop.
This file contains 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
var invertTree = function(root) { | |
if(root === null) return null; | |
const [invertedLeft, invertedRight] = [invertTree(root.left), invertTree(root.right)]; | |
([root.left, root.right] = [invertedRight, invertedLeft]); | |
return root; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
52ms