You are given a balance scale to weigh some items. Unfortunately the weights you use as counterbalances are not accurate. Some of them may be marked incorrectly - either 1 gram too heavy or one gram too light. (Some may be marked correctly.)
You are given a int[] **weights** representing the set of weights you have. The i-th of your weights is marked by **weights**[i] grams. The subset of your weights is called *good* if it's possible that all the real weights in it sum exactly to **testWeight**. Find the good subset with the minimum possible number of weights and return the number of weights in it. If there is no good subset of weights, your method should return -1. |