Take out different no of balls from each bag and find the sum for eg: 1 ball from first bag, 3 ball from second bag, 5 balls from third bag, 4 balls from fourth bag.

Now in ideal case if all balls are of same size their weight should be (1+3+5+4) * 100 = 1300 but it is not

If first bag is of 90 gm ball weight will be 1300 - 1*10 = 1290

If second bag is of 90 gm ball weight will be 1300 - 3*10 = 1270

If third bag is of 90 gm ball weight will be 1300 - 5*10 = 1250

If fourth bag is of 90 gm ball weight will be 1300 - 4*10 = 1260

In simple terms substract the actual weight from ideal weight and divide by 10 you will get the no of 90 gm balls & then the corresponding bag.