Practice Bag of Tokens
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Begin with the given power and score 0. Each token can be used once: playing it face up requires at least its value in power, spends that power and adds one point; playing it face down requires at least one point, spends one point and adds the token's value to power. Tokens may be chosen in any order and some may remain unused. Return the highest score achievable.
Source: Bag of Tokens on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
tokens = [100], power = 50
0
# Example 2
tokens = [200,100], power = 150
1
# Example 3
tokens = [100,200,300,400], power = 200
2
Constraints
Related LeetCode Problems
Practice more problems similar to Bag of Tokens.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.