1475. Final Prices With a Special Discount in a Shop
You are given an integer array
prices
whereprices[i]
is the price of theith
item in a shop.There is a special discount for items in the shop. If you buy the
ith
item, then you will receive a discount equivalent toprices[j]
wherej
is the minimum index such thatj > i
andprices[j] <= prices[i]
. Otherwise, you will not receive any discount at all.Return an integer array
answer
whereanswer[i]
is the final price you will pay for theith
item of the shop, considering the special discount.
1 | class Solution { |