Practice Maximum Points After Enemy Battles
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
Start with currentEnergy, zero points, and all enemies in enemyEnergies unmarked. You may fight an unmarked enemy whose energy you can afford: subtract that energy and gain one point, leaving the enemy unmarked. Alternatively, if you already have at least one point, you may mark an unmarked enemy and add its energy to yours; this action does not spend a point. Repeat either action any number of times and return the maximum points obtainable.
Source: Maximum Points After Enemy Battles on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
enemyEnergies = [3,2,2], currentEnergy = 2
3
# Example 2
enemyEnergies = [2] , currentEnergy = 10
5
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Points After Enemy Battles.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.