1/**
2 * Definition for a binary tree node.
3 * function TreeNode(val, left, right) {
4 * this.val = (val===undefined ? 0 : val)
5 * this.left = (left===undefined ? null : left)
6 * this.right = (right===undefined ? null : right)
7 * }
8 */
9/**
10 * @param {TreeNode} root
11 * @return {TreeNode}
12 */
13var invertTree = function (root) {
14 if (root === null) return null
15 const left = invertTree(root.left)
16 const right = invertTree(root.right)
17 root.left = right
18 root.right = left
19 return root
20};