# LeetCode - 1475. Final Prices With a Special Discount in a Shop ### 題目網址:https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop/ ###### tags: `LeetCode` `Easy` `堆疊(Stack)` ```cpp= /* -LeetCode format- Problem: 1475. Final Prices With a Special Discount in a Shop Difficulty: Easy by Inversionpeter */ class Solution { public: vector<int> finalPrices(vector<int>& prices) { stack <int> increasing; for (int i = 0; i != prices.size(); ++i) { while (!increasing.empty() && prices[increasing.top()] >= prices[i]) { prices[increasing.top()] -= prices[i]; increasing.pop(); } increasing.push(i); } return prices; } }; ```