Wonderful! The difference here is that Car X is going in the opposite direction, so, its velocity becomes negative. $$v_{\text{XY}} = v_{\text{XE}} + v_{\text{EY}}$$, with $$v_{\text{XE}} = 40$$. $$v_{\text{EY}} = - v_{\text{YE}} = 30$$. Therefore, $$v_{\text{YX}} = 40 + 30 = 70$$.
You had earlier answered correctly that when the cars are moving in opposite directions, the accident will be worse. We can see that quantitatively here. In Case 1, the relative velocity is $$10 \, \mathrm{km/h}$$, whereas in Case 2, the relative velocity is $$70 \, \mathrm{km/h}$$. As the magnitude of velocity is higher in the second case, the impact will be higher.