We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b16c8f5 commit 7e5b79bCopy full SHA for 7e5b79b
226-invert-binary-tree.js
@@ -48,3 +48,25 @@ const invertTree = function (root) {
48
}
49
return root
50
51
+
52
+// anoother
53
54
+/**
55
+ * Definition for a binary tree node.
56
+ * function TreeNode(val, left, right) {
57
+ * this.val = (val===undefined ? 0 : val)
58
+ * this.left = (left===undefined ? null : left)
59
+ * this.right = (right===undefined ? null : right)
60
+ * }
61
+ */
62
63
+ * @param {TreeNode} root
64
+ * @return {TreeNode}
65
66
+const invertTree = function(root) {
67
+ if(root == null) return root
68
+ let tmp = root.left
69
+ root.left = invertTree(root.right)
70
+ root.right = invertTree(tmp)
71
+ return root
72
+};
0 commit comments