We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1cd9107 commit b3489bbCopy full SHA for b3489bb
허현빈/11주차/Symmetric 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 {boolean}
12
13
+var isSymmetric = function(root) {
14
+ const isMirror = (left, right) =>{
15
+ if(!left && !right) return true
16
+ if(!left || !right) return false
17
+ if(left.val !== right.val) return false
18
+ return isMirror(left.left, right.right) && isMirror(left.right, right.left)
19
+ }
20
+ return isMirror(root.left, root.right)
21
+};
0 commit comments