Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

invert binary tree js

function invertTree(node) {
  if(!node) return;
  [node.left, node.right] = [node.right, node.left];
  invertTree(node.left);
  invertTree(node.right);
  return node;
}
 
PREVIOUS NEXT
Tagged: #invert #binary #tree #js
ADD COMMENT
Topic
Name
6+4 =