Skip to content

Practice Maximum Total Reward Using Operations II

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#3181
LeetCode Problem

Maximum Total Reward Using Operations II

Problem Statement

Start with total reward x = 0 and no used indices in rewardValues. You may select an unused index only when its reward is strictly greater than x. Add that reward to x and mark its index as used. Return the largest total obtainable by choosing the order of selections optimally.

Source: Maximum Total Reward Using Operations II on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
rewardValues = [1,1,3,3]
Output
4

# Example 2

Input
rewardValues = [1,6,4,3,2]
Output
11

Constraints

1 <= rewardValues.length <= 5 * 10^4
1 <= rewardValues[i] <= 5 * 10^4

Related LeetCode Problems

Practice more problems similar to Maximum Total Reward Using Operations II.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.