we know that
Percent by mass (m/m) is the mass of solute divided by the total mass of the solution, multiplied by 100 %
so
mass of solute=Percent by mass*total mass of the solution/100%
case a) 150 g of a 12% solution
mass a solute=12%*150 g/100%------> 18 g
case b) 120 g of a 15% solution
mass a solute=15%*120 g/100%------> 18 g
the mass of solute (salt) is the same both cases