1475. Final Prices With a Special Discount in a Shop
Содержание
class Solution:
def finalPrices(self, prices: List[int]) -> List[int]:
stk = []
res = prices[:]
for i in range(len(prices) - 1, -1, -1):
while stk and prices[stk[-1]] > prices[i]:
stk.pop()
if stk:
res[i] -= prices[stk[-1]]
stk.append(i)
return res