According to the question, we can draw the following diagram
Here, T is the tension in the string. In equilibrium condition, For mass m1,T−m1g=m1a......(i) For mass m2,m2g−T=m2a......(ii) After adding Eqs. (i) and (ii), we get m2g−m1g=m1a+m2a (m2−m1)g=(m1+m2)a a=