其他分享
首页 > 其他分享> > leetcode-1475-商品折扣后的最终价格

leetcode-1475-商品折扣后的最终价格

作者:互联网

题目描述:

 

 

 

 提交:

class Solution:
    def finalPrices(self, prices: List[int]) -> List[int]:
        res = []
        for i in range(len(prices)):
            for j in range(i,len(prices)):
                if j > i and prices[j] <= prices[i]:
                    res.append(prices[i] - prices[j])
                    break
                if j == len(prices) - 1:
                    res.append(prices[i])
        return res

 

标签:int,折扣,List,Solution,len,range,1475,prices,leetcode
来源: https://www.cnblogs.com/oldby/p/13153827.html