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
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 0ms, memory 17.3MB, accepted 2025-12-29.
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