If T = the tension in the cord, then the equations are as follows if a = the acceleration, s = seconds
Perform a force balance on each string section for the masses:
For the 4kg mass: T - (4kg)(9.8m/s2) = (4kg)a
For the 21 kg mass: T - (21kg)(9.8m/s2) = -(21kg)a
Eliminating T from both equations you find that a = 6.664 m/s2