Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Halve Array Sum

Minimum Operations to Halve Array Sum gives an array of positive integers. Replace chosen elements with exactly half their values and return the fewest operations needed to reduce the total sum by at least half.

Statement

You are given an array nums of positive integers. In one operation, you may choose any element from nums and replace it with exactly half of its value.

Return the minimum number of operations required to reduce the total sum of nums by at least half of its initial sum.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤107\leq 10^7

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Halve Array Sum

Minimum Operations to Halve Array Sum gives an array of positive integers. Replace chosen elements with exactly half their values and return the fewest operations needed to reduce the total sum by at least half.

Statement

You are given an array nums of positive integers. In one operation, you may choose any element from nums and replace it with exactly half of its value.

Return the minimum number of operations required to reduce the total sum of nums by at least half of its initial sum.

Constraints:

  • 1≤1 \leq nums.length ≤105\leq 10^5

  • 1≤1 \leq nums[i] ≤107\leq 10^7