📜  反转二叉树javascript代码示例

📅  最后修改于: 2022-03-11 15:03:39.353000             🧑  作者: Mango

代码示例1
function invertTree(head) {
  if (head) {
    var temp = head.left;
    head.left = head.right;
    head.right = temp;

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

  return head;
}