Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Choose the pile with the maximum number of stones each time.
Use a data structure that helps you find the mentioned pile each time efficiently.
One such data structure is a Priority Queue.