-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Zanger67/leetcode
authored and
Zanger67/leetcode
committed
Dec 18, 2024
1 parent
65dc832
commit b5f7287
Showing
10 changed files
with
60 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
markdowns/_1475. Final Prices With a Special Discount in a Shop.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# 1475. [Final Prices With a Special Discount in a Shop](<https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop>) | ||
|
||
*All prompts are owned by LeetCode. To view the prompt, click the title link above.* | ||
|
||
*[Back to top](<../README.md>)* | ||
|
||
------ | ||
|
||
> *First completed : December 18, 2024* | ||
> | ||
> *Last updated : December 18, 2024* | ||
------ | ||
|
||
> **Related Topics** : **[Array](<by_topic/Array.md>), [Stack](<by_topic/Stack.md>), [Monotonic Stack](<by_topic/Monotonic Stack.md>)** | ||
> | ||
> **Acceptance Rate** : **78.81 %** | ||
------ | ||
|
||
## Solutions | ||
|
||
- [e1475.py](<../my-submissions/e1475.py>) | ||
### Python | ||
#### [e1475.py](<../my-submissions/e1475.py>) | ||
```Python | ||
class Solution: | ||
def finalPrices(self, prices: List[int]) -> List[int]: | ||
output = [-1] * len(prices) | ||
|
||
for i in range(len(prices) - 1, -1, -1) : | ||
price = prices[i] | ||
maxx = 0 | ||
for disc in prices[i + 1:] : | ||
if disc > price : | ||
continue | ||
maxx = disc | ||
break | ||
output[i] = price - maxx | ||
|
||
return output | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.