## [1475\. 商品折扣后的最終價格](https://leetcode-cn.com/problems/final-prices-with-a-special-discount-in-a-shop/)
#### 思路
首先遍歷商品,找到第一個滿足條件的商品,計算出優惠后的價格,寫入到`結果數組`中
#### 代碼
python3
```
class Solution:
def finalPrices(self, prices: List[int]) -> List[int]:
result = prices[::]
for i in range(len(prices)):
for j in range(i+1, len(prices)):
if prices[j] <= prices[i]:
result[i] -= prices[j]
break
return result
```
**改進思路**
看到右邊第一個,考慮是否可以用單調棧來求解。需要有一定思考過程,周賽考慮時間因素沒有選用這種方案,感興趣的小伙伴可以嘗試一下。
- 目錄
- excel-sheet-column-number
- divide-two-integers
- house-robber
- fraction-to-recurring-decimal
- profile
- kids-with-the-greatest-number-of-candies
- qiu-12n-lcof
- new-21-game
- product-of-array-except-self
- minimum-depth-of-binary-tree
- univalued-binary-tree
- shun-shi-zhen-da-yin-ju-zhen-lcof
- permutations
- satisfiability-of-equality-equations
- word-ladder-ii
- ba-shu-zi-fan-yi-cheng-zi-fu-chuan-lcof
- palindrome-number
- network-delay-time
- daily-temperatures
- longest-common-prefix
- sum-of-mutated-array-closest-to-target
- 周賽專題
- make-two-arrays-equal-by-reversing-sub-arrays
- check-if-a-string-contains-all-binary-codes-of-size-k
- course-schedule-iv
- cherry-pickup-ii
- maximum-product-of-two-elements-in-an-array
- maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts
- reorder-routes-to-make-all-paths-lead-to-the-city-zero
- probability-of-a-two-boxes-having-the-same-number-of-distinct-balls
- shuffle-the-array
- the-k-strongest-values-in-an-array
- design-browser-history
- paint-house-iii
- final-prices-with-a-special-discount-in-a-shop