Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bag of Tokens Problem Solution In Java #879

Open
pratyushshekhar opened this issue Oct 9, 2021 · 1 comment
Open

Bag of Tokens Problem Solution In Java #879

pratyushshekhar opened this issue Oct 9, 2021 · 1 comment

Comments

@pratyushshekhar
Copy link

Question:- You have an initial power of power, an initial score of 0, and a bag of tokens where tokens[i] is the value of the ith token (0-indexed).

Your goal is to maximize your total score by potentially playing each token in one of two ways:

If your current power is at least tokens[i], you may play the ith token face up, losing tokens[i] power and gaining 1 score.
If your current score is at least 1, you may play the ith token face down, gaining tokens[i] power and losing 1 score.
Each token may be played at most once and in any order. You do not have to play all the tokens.

Return the largest possible score you can achieve after playing any number of tokens.

@pratyushshekhar
Copy link
Author

I have a solution for this problem. @abhishekdoifode1 please assign me this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant