We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7db3678 commit ba90acfCopy full SHA for ba90acf
허현빈/9주차/invert tree.js
@@ -0,0 +1,21 @@
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
13
+var invertTree = function (root) {
14
+ if (!root) return null;
15
+
16
+ const temp = root.left;
17
+ root.left = invertTree(root.right);
18
+ root.right = invertTree(temp);
19
20
+ return root;
21
+};
0 commit comments