The specific heat of water is 4.18 J/gC. This means that if 4.18 joules of energy (heat) is applied to a gram of water, the temperature will increase one degree Celsius.
The question has water increasing from 10C to 30C. This means that the water is increasing by 30-10=20C. There is also 20 grams of water. So, the amount of heat energy needed to do this is (4.18*20*20)=1672J