Search
⌘K

Leetcode 2835. Minimum Operations to Form Subsequence With Target Sum

Given an array of powers of two where you can replace any 2^k with two 2^(k-1) at cost 1 (the halves are appended to the array), find the minimum number of such splits so that some subsequence sums to target, or return -1 if impossible. The core challenge is greedily balancing counts of each power-of-two to match the target's binary representation by splitting larger powers as needed.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.