2835. Minimum Operations to Form Subsequence With Target Sum
You are given a 0-indexed array
numsconsisting of non-negative powers of2, and an integertarget.In one operation, you must apply the following changes to the array:
- Choose any element of the array
nums[i]such thatnums[i] > 1.- Remove
nums[i]from the array.- Add two occurrences of
nums[i] / 2to the end ofnums.Return the *minimum number of operations you need to perform so that
numscontains a subsequence whose elements sum to*target. If it is impossible to obtain such a subsequence, return-1.A subsequence is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements.