C# simple solution


  • 0
    T
    public bool IsSameTree(TreeNode p, TreeNode q) {
            if(p!=null && q!=null && p.val==q.val)
            {
               return true && IsSameTree(p.left,q.left) && IsSameTree(p.right,q.right);
            }
            if(p==q)
            {
                return true;
            }
            return false;
        }
    

Log in to reply
 

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