← All problemsSign in

2558. Take Gifts From the Richest Pile

LeetCodeArrayHeap (Priority Queue)SimulationOpen on judge ↗

You are given an integer array gifts denoting the number of gifts in various piles. Every second, you do the following: - Choose the pile with the maximum number of gifts. - If there is more than one pile with the maximum number of gifts, choose any. - Reduce the number of gifts in the pile to the floor of the square root of the original number of gifts in the pile. Return the number of gifts

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start