Solution (source code)

= Solution

Let $u_j^{(1)}=u_j$ and $u_j^{(0)}=1-u_j$. Applying the <Nelson–Aalen estimator> separately to group $k$ gives
$$
\widehat H_j^{(k)}
=\sum_{\ell=1}^{j}\frac{u_\ell^{(k)}}{r_\ell^{(k)}},
$$
with a zero contribution when the event at $a_\ell$ occurs in the other group.