To put it more generally, for the specified class of problem, you have 2 mixtures of the same 2 substances. Classify one substance (e.g. grams of salt) as the numerator, and either the other substance (e.g. grams of water) or their sum (e.g. grams of saltwater) as the denominator. But be sure to pick one representation and stick with it!
Add the numerators and denominators separately to express the problem algebraically, then solve.
To put it more generally, for the specified class of problem, you have 2 mixtures of the same 2 substances. Classify one substance (e.g. grams of salt) as the numerator, and either the other substance (e.g. grams of water) or their sum (e.g. grams of saltwater) as the denominator. But be sure to pick one representation and stick with it!
Add the numerators and denominators separately to express the problem algebraically, then solve.