Glad to share my JAVA solution with U. Simple.


  • 0
    Y
    public class Solution {
        public boolean isSymmetric(TreeNode root) {
            if(root == null) return true;
            return check(root.left, root.right);
        }
        private boolean check(TreeNode m, TreeNode n){
            if(m == null && n == null) return true;
            if(m == null || n == null) return false;
            if(m.val != n.val) return false;
            return check(m.right, n.left) && check(m.left, n.right);
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.