Skip to content

Practice Remove Stones to Minimize the Total

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1962
LeetCode Problem

Remove Stones to Minimize the Total

Problem Statement

Perform exactly k operations on piles. Each operation chooses a pile and removes floor(pileSize / 2) stones from it. The same pile may be chosen repeatedly. Return the smallest possible total remaining stones.

Source: Remove Stones to Minimize the Total on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
piles = [5,4,9], k = 2
Output
12

# Example 2

Input
piles = [4,3,6,7], k = 3
Output
12

Constraints

1 <= piles.length <= 10^5
1 <= piles[i] <= 10^4
1 <= k <= 10^5

Related LeetCode Problems

Practice more problems similar to Remove Stones to Minimize the Total.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.