2dbi

Remove Stones to Minimize the Total

viaLeetCode

Given an array of pile sizes and an integer k, perform k operations; in each operation pick the largest pile and remove half of it (floor(pile/2)) from that pile. Return the minimum possible total sum of stones after k operations. Solve with a max-heap, repeatedly halving the top element.

Add a follow-up question they asked
No follow-ups yet. Be the first to add one.
asked …
LeaderboardSalary
Language
Account