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 9716591 commit 6ddb818Copy full SHA for 6ddb818
invert-binary-tree/byol-han.js
@@ -0,0 +1,21 @@
1
+/**
2
+ * https://leetcode.com/problems/invert-binary-tree/submissions/1651537941/
3
+ * Definition for a binary tree node.
4
+ * function TreeNode(val, left, right) {
5
+ * this.val = (val===undefined ? 0 : val)
6
+ * this.left = (left===undefined ? null : left)
7
+ * this.right = (right===undefined ? null : right)
8
+ * }
9
+ */
10
11
+ * @param {TreeNode} root
12
+ * @return {TreeNode}
13
14
+var invertTree = function (root) {
15
+ if (root === null) return null;
16
+
17
+ // 왼쪽과 오른쪽 자식 노드 바꾸기
18
+ [root.left, root.right] = [invertTree(root.right), invertTree(root.left)];
19
20
+ return root;
21
+};
0 commit comments