Tap here to switch tabs
Problem
Submissions

Problem: Minimum Operations to Halve Array Sum

med
30 min
Try to solve the Minimum Operations to Halve Array Sum problem.

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

med
30 min
Try to solve the Minimum Operations to Halve Array Sum problem.

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