Team Ai
Datasetpublic

FPEvalRepoPublic/LeetCodeMetaData

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes399downloads
maximum-total-reward-using-operations-i.json31 linesDownload Raw Back to root
1{2  "id": 3442,3  "name": "maximum-total-reward-using-operations-i",4  "difficulty": "Medium",5  "link": "https://leetcode.com/problems/maximum-total-reward-using-operations-i/",6  "date": "2024-06-02",7  "task_description": "You are given an integer array `rewardValues` of length `n`, representing the values of rewards. Initially, your total reward `x` is 0, and all indices are **unmarked**. You are allowed to perform the following operation **any** number of times: Choose an **unmarked** index `i` from the range `[0, n - 1]`. If `rewardValues[i]` is **greater** than your current total reward `x`, then add `rewardValues[i]` to `x` (i.e., `x = x + rewardValues[i]`), and **mark** the index `i`. Return an integer denoting the **maximum **_total reward_ you can collect by performing the operations optimally. **Example 1:** **Input:** rewardValues = [1,1,3,3] **Output:** 4 **Explanation:** During the operations, we can choose to mark the indices 0 and 2 in order, and the total reward will be 4, which is the maximum. **Example 2:** **Input:** rewardValues = [1,6,4,3,2] **Output:** 11 **Explanation:** Mark the indices 0, 2, and 1 in order. The total reward will then be 11, which is the maximum. **Constraints:** `1 <= rewardValues.length <= 2000` `1 <= rewardValues[i] <= 2000`",8  "test_case": [9    {10      "label": "Example 1",11      "input": "rewardValues = [1,1,3,3]",12      "output": "4 "13    },14    {15      "label": "Example 2",16      "input": "rewardValues = [1,6,4,3,2]",17      "output": "11 "18    }19  ],20  "constraints": [21    "Choose an unmarked index i from the range [0, n - 1].",22    "If rewardValues[i] is greater than your current total reward x, then add rewardValues[i] to x (i.e., x = x + rewardValues[i]), and mark the index i.",23    "1 <= rewardValues.length <= 2000",24    "1 <= rewardValues[i] <= 2000"25  ],26  "python_template": "class Solution(object):\n    def maxTotalReward(self, rewardValues):\n        \"\"\"\n        :type rewardValues: List[int]\n        :rtype: int\n        \"\"\"\n        ",27  "java_template": "class Solution {\n    public int maxTotalReward(int[] rewardValues) {\n        \n    }\n}",28  "metadata": {29    "func_name": "maxTotalReward"30  }31}