We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 81cad5f commit 160ec6dCopy full SHA for 160ec6d
二叉树/对称二叉树-101.js
@@ -0,0 +1,28 @@
1
+/**
2
+ * Definition for a binary tree node.
3
+ * function TreeNode(val) {
4
+ * this.val = val;
5
+ * this.left = this.right = null;
6
+ * }
7
+ */
8
9
+ * @param {TreeNode} root
10
+ * @return {boolean}
11
12
+var isSymmetric = function (root) {
13
+ if (!root) return true
14
+ let helper = (left, right) => {
15
+ if (!left && !right) {
16
+ return true
17
+ }
18
+ if (!left || !right) {
19
+ return false
20
21
+ if (left.val === right.val) {
22
+ return helper(left.left, right.right) && helper(left.right, right.left)
23
+ } else {
24
25
26
27
+ return helper(root, root)
28
+}
0 commit comments