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 5176b51 commit f7136a1Copy full SHA for f7136a1
scripts/algorithms/S/Symmetric Tree/Symmetric Tree.java
@@ -1,13 +1,14 @@
1
+// Runtime: 1 ms (Top 64.02%) | Memory: 42.7 MB (Top 25.40%)
2
class Solution {
3
public boolean isSymmetric(TreeNode root) {
4
return isSymmetric(root.left,root.right);
5
}
-
6
+
7
public boolean isSymmetric(TreeNode rootLeft, TreeNode rootRight) {
8
if(rootLeft == null && rootRight == null) {return true;}
9
if(rootLeft == null || rootRight == null) {return false;}
10
if (rootLeft.val != rootRight.val) {return false;}
11
else
12
return isSymmetric(rootLeft.right, rootRight.left) && isSymmetric(rootLeft.left, rootRight.right);
13
-}
14
+}
0 commit comments