Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

Commit

Permalink
leetcode: finished #264
Browse files Browse the repository at this point in the history
  • Loading branch information
xqm32 committed Sep 18, 2023
1 parent f5be8af commit 00a32ad
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions content/leetcode/2023/9.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,38 @@ title: 2023.9
draft: false
---

# 2023.9.18

```python
#
# @lc app=leetcode.cn id=264 lang=python3
#
# [264] 丑数 II
#


# @lc code=start
class Solution:
def nthUglyNumber(self, n: int) -> int:
import heapq

heap = [1]
seen = set()
seen.add(1)
factors = [2, 3, 5]
for i in range(n):
ugly = heapq.heappop(heap)
for factor in factors:
new_ugly = ugly * factor
if new_ugly not in seen:
seen.add(new_ugly)
heapq.heappush(heap, new_ugly)
return ugly


# @lc code=end
```

# 2023.9.17

```python
Expand Down

0 comments on commit 00a32ad

Please sign in to comment.