If you add together the fruit cans and the vegetable cans, you will get 84 cans in total. Divide 84 and 2.
If William only has two bags, then he can put 42 cans in each bag to make them equal.
And if the assignment that you're working on mentions more bags than two, just work your way down the line with division.