Weight Sets for an Exact Load
Medium · Weight Sets for an Exact Load
A warehouse has weights of several kinds; their masses are listed in the array `weights` (all different). There is an unlimited supply of each kind. You need to balance a load of mass `total`: find every set of weights whose combined mass is exactly `total`. A set is defined by how many weights of each kind it contains, so `[3, 3, 4]` and `[4, 3, 3]` are the same set and must appear only once. Return the list of all sets. The sets, and the weights inside each set, may be listed in any order.…
Solve the problem →