Bag of Tokens

Medium · Greedy · about 15 minutes

Asked at Google, Amazon, Microsoft.

You start with power and score 0. Each token value t can be played once, either face up (spend t power to gain 1 score, if power ≥ t) or face down (spend 1 score to gain t power, if score ≥ 1). Return the maximum score you can reach.

Related guides