Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
How can you keep track of the largest gifts in the array
What is an efficient way to find the square root of a number?
Can you keep adding up the values of the gifts while ensuring they are in a certain order?
Can we use a priority queue or heap here?