LeetCode solutions

1570. Final Prices With a Special Discount in a Shop

My accepted Python solution to LeetCode problem 1570, Final Prices With a Special Discount in a Shop, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.3MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.3MB, accepted 2025-12-29.

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

Source