Maximum Number of Coins You Can Get

There are 3n piles of coins of varying size. In each step, you will choose any 3 piles of coins. Of those 3 piles, Alice will pick the pile with the maximum number of coins, you will pick the next pile with the maximum number of coins, and your friend Bob will pick the last pile. Repeat until there are no more piles of coins. Given an integer array piles where piles[i] is the number of coins in the i-th pile, return the maximum number of coins you can get.

Constraints

  • 3 <= piles.length <= 100000
  • piles.length % 3 == 0
  • 1 <= piles[i] <= 10000
Saving… · 2 lines
class Solution:
def maximumNumberOfCoinsYouCanGet(self, piles: List[int]) -> int:
Console

Click Run to execute sample tests.