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 652f0c1 commit c0f15feCopy full SHA for c0f15fe
src/com/gatsby/_101SymmetricTree.java
@@ -0,0 +1,26 @@
1
+package com.gatsby;
2
+
3
+/**
4
+ * @ClassName: _101SymmetricTree
5
+ * @Description: leetcode 101 对称二叉树
6
+ * @author: Gatsby
7
+ * @date: 2022/5/15 20:03
8
+ */
9
10
+public class _101SymmetricTree {
11
+ private boolean isSymmetric(TreeNode left, TreeNode right) {
12
+ if (left == null && right == null) return true;
13
+ if (left != null || right != null) return false;
14
+ if (left.val != right.val) return false;
15
16
+ return isSymmetric(left.right, right.left) && isSymmetric(right.left, left.right);
17
+ }
18
19
+ public boolean isSymmetric(TreeNode root) {
20
+ if (root == null) return true;
21
22
+ return isSymmetric(root.left, root.right);
23
24
+}
25
26
0 commit comments