Practice Maximum Total Damage With Spell Casting
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Maximum Total Damage With Spell Casting
Problem Statement
A magician has various spells. You are given an array power, where each element represents the damage of a spell. Multiple spells can have the same damage value. It is a known fact that if a magician decides to cast a spell with a damage of power[i], they cannot cast any spell with a damage of power[i] - 2, power[i] - 1, power[i] + 1, or power[i] + 2. Each spell can be cast only once. Return the maximum possible total damage that a magician can cast.
Source: Maximum Total Damage With Spell Casting on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
power = [1,1,3,4]
6
# Example 2
power = [7,1,6,6]
13
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Total Damage With Spell Casting.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.