Skip to content

Instantly share code, notes, and snippets.

@youngdo212
Created June 9, 2018 08:22
Show Gist options
  • Save youngdo212/a94a15d7029c2a03fdfeb693482e25dd to your computer and use it in GitHub Desktop.
Save youngdo212/a94a15d7029c2a03fdfeb693482e25dd to your computer and use it in GitHub Desktop.
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;
};
@youngdo212
Copy link
Author

52ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment