Easy JAVA recursive solution


#1

public class Solution {
public int isSameTree(TreeNode A, TreeNode B) {
boolean x = isIdentical(A,B);
return x == true?1:0;
}

public boolean isIdentical(TreeNode A, TreeNode B){
   if(A == null && B==null){
        return true;
    } 
    
    if(A!=null && B!=null){
        return (A.val == B.val && isIdentical(A.left,B.left) 
        && isIdentical(A.right,B.right));
    }
    return false;
}

}