3180. Maximum Total Reward Using Operations I
You are given an integer array
rewardValues
of lengthn
, 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 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.