2022.3.15
4 4this.val = (val===undefined ? 0 : val)this.left = (left===undefined ? null : left)this.right = (right===undefined ? null : right)
var invertTree = function(root) {
// 递归 终止条件
if (root == null) {
return root
}
// 递归的逻辑
[root.left, root.right] = [invertTree(root.right), invertTree(root.left)]
return root
}最后更新于