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