Open pwstrick opened 4 years ago
226. 翻转二叉树
/** * Definition for a binary tree node. * function TreeNode(val) { * this.val = val; * this.left = this.right = null; * } */ /** * @param {TreeNode} root * @return {TreeNode} */ var invertTree = function(root) { if(!root) return null; let temp = root.right; root.right = root.left; root.left = temp; invertTree(root.left); invertTree(root.right); return root; };
226. 翻转二叉树