Leetcode in Java && Oracle
423 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
image_2022-09-25_15-53-22.png
39.6 KB
#N101. Symmetric Tree
problem link
#solution
class Solution {
public boolean isSymmetric(TreeNode root) {
return root==null||func(root.left, root.right);
}
public boolean func(TreeNode left, TreeNode right){
if(left==null && right==null) return true;
if(left==null ^ right==null || left.val!=right.val) return false;
return func(left.left, right.right) && func(left.right, right.left);
}
}
2👍1