total_loss
to 0 and max_cost
to 0.transactions
list.
a. Calculate the loss for the current transaction as cost - cashback
.
b. If the loss is positive, add it to total_loss
.
c. Update max_cost
to be the maximum of itself and the minimum between the cost and the cashback of the current transaction.total_loss
and max_cost
.