C++ recursive O(n)


#1
    int Solution::isSameTree(TreeNode* A, TreeNode* B) {
        if(A==NULL and B==NULL)return 1;
        if(A==NULL)return 0;
        if(B==NULL)return 0;
        int ok=1;
        ok=isSameTree(A->left,B->left)&isSameTree(A->right,B->right);
        return ok&(A->val==B->val);
    }