Leetcode 1475. Final Prices With a Special Discount in a Shop

Posted SnailTyan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Leetcode 1475. Final Prices With a Special Discount in a Shop相关的知识,希望对你有一定的参考价值。

文章作者:Tyan
博客:noahsnail.com  |  CSDN  |  简书

1. Description

Final Prices With a Special Discount in a Shop

2. Solution

  • Version 1
class Solution:
    def finalPrices(self, prices: List[int]) -> List[int]:
        n = len(prices)
        for i in range(n-1):
            for j in range(i+1, n):
                if prices[i] >= prices[j]:
                    prices[i] = prices[i] - prices[j]
                    break
        return prices

Reference

  1. https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop/

以上是关于Leetcode 1475. Final Prices With a Special Discount in a Shop的主要内容,如果未能解决你的问题,请参考以下文章