Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
@YCor let's juct stick with the edit made by user43326, that $H^n(G,\mathbb{Z})\cong H^n(H,\mathbb{Z})$ $\forall n\in \mathbb{Z} _{\geq 0}$ as abelian groups.
@DerekHolt Thanks for the interest. Of course the isomorphism couldn't be induced by a homomorphism $f:G\to H$ because otherwise it would imply $f$ is an isomorphism (jstor.org/stable/2042568 - it's about homology groups, actually, but I think the similar argument can be applied). So I just want $H^*(G,\mathbb{Z})\cong H^*(H,\mathbb{Z})$ as user43326 wrote.