3180. Maximum Total Reward Using Operations I
You are given an integer array
rewardValuesof lengthn, representing the values of rewards.Initially, your total reward
xis 0, and all indices are unmarked. You are allowed to perform the following operation any number of times:
- Choose an unmarked index
ifrom the range[0, n - 1].- If
rewardValues[i]is greater than your current total rewardx, then addrewardValues[i]tox(i.e.,x = x + rewardValues[i]), and mark the indexi.Return an integer denoting the maximum total reward you can collect by performing the operations optimally.