4040. Minimum Operations to Form Subset Sum I
You are given an integer array
numsand an integersum.In one operation, choose an element with current value
xand replace it with either2 * xorfloor(x / 2).For each element, all multiplication operations performed on it must occur before any division operations performed on it.
Return the minimum number of operations needed so that some subset of the resulting array has a sum exactly equal to
sum. If it is impossible, return -1.The
floor()function returns the integer part of the division.
1 |
|