Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

invert binary tree javascript

function invertTree(head) {
  if (head) {
    var temp = head.left;
    head.left = head.right;
    head.right = temp;

    invertTree(head.left);
    invertTree(head.right);
  }

  return head;
}
 
PREVIOUS NEXT
Tagged: #invert #binary #tree #javascript
ADD COMMENT
Topic
Name
8+7 =