let invertTree = function(root) { if (root) { const right = root.right; root.right = invertTree(root.left) root.left = invertTree(right) return root; } return null; };
Categories
let invertTree = function(root) { if (root) { const right = root.right; root.right = invertTree(root.left) root.left = invertTree(right) return root; } return null; };