Thanksgiving Sale: Use Coupon Code THANKS25 to Get Extra 25% Off.
ans to store the scores for each prefix.sum and mx to 0. sum will hold the running sum of the conversion values, and mx will hold the maximum value seen so far.n in the input array nums.
a. Update mx to be the maximum of mx and the current element n.
b. Calculate the conversion value for the current element as n + mx.
c. Add the conversion value to sum to update the running sum.
d. Append sum to the ans list.ans list containing the scores for all prefixes.