1962. Remove Stones to Minimize the Total
https://leetcode.com/problems/remove-stones-to-minimize-the-total
Description
You are given a 0-indexed integer array piles
, where piles[i]
represents the number of stones in the ith
pile, and an integer k
. You should apply the following operation exactly k
times:
Choose any
piles[i]
and removefloor(piles[i] / 2)
stones from it.
Notice that you can apply the operation on the same pile more than once.
Return the minimum possible total number of stones remaining after applying the k
operations.
floor(x)
is the greatest integer that is smaller than or equal to x
(i.e., rounds x
down).
Example 1:
Example 2:
Constraints:
1 <= piles.length <= 105
1 <= piles[i] <= 104
1 <= k <= 105
ac
Previous1961. Check If String Is a Prefix of ArrayNext1963. Minimum Number of Swaps to Make the String Balanced
Last updated