The idea of this problem is that the water with the higher temperature will lose heat and that the water with the lower temperature will gain the same amount of heat.
Mathematically, this is expressed as
Heat lost by a system is negative, while heat gained by a system is positive, hence the minus sign used in the above equation.
The equation that establishes a relationship between heat gained or lost and change in temperature looks like this
So, you mix the two samples together and a thermal equilibrium is reached, meaining that the final temperature will be the same for both samples.
This means that you can write
which is equivalent to