Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
maximum-total-damage-with-spell-casting.json29 linesDownload Raw Back to root
1{2  "id": 3437,3  "name": "maximum-total-damage-with-spell-casting",4  "difficulty": "Medium",5  "link": "https://leetcode.com/problems/maximum-total-damage-with-spell-casting/",6  "date": "2024-06-09",7  "task_description": "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. **Example 1:** **Input:** power = [1,1,3,4] **Output:** 6 **Explanation:** The maximum possible damage of 6 is produced by casting spells 0, 1, 3 with damage 1, 1, 4. **Example 2:** **Input:** power = [7,1,6,6] **Output:** 13 **Explanation:** The maximum possible damage of 13 is produced by casting spells 1, 2, 3 with damage 1, 6, 6. **Constraints:** `1 <= power.length <= 105` `1 <= power[i] <= 109`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "power = [1,1,3,4]",12      "output": "6 "13    },14    {15      "label": "Example 2",16      "input": "power = [7,1,6,6]",17      "output": "13 "18    }19  ],20  "constraints": [21    "1 <= power.length <= 105",22    "1 <= power[i] <= 109"23  ],24  "python_template": "class Solution(object):\n    def maximumTotalDamage(self, power):\n        \"\"\"\n        :type power: List[int]\n        :rtype: int\n        \"\"\"\n        ",25  "java_template": "class Solution {\n    public long maximumTotalDamage(int[] power) {\n        \n    }\n}",26  "metadata": {27    "func_name": "maximumTotalDamage"28  }29}