堆
from heapq import heappop, heappush
class Solution:
def nthUglyNumber(self, n):
q = [1]
vis = {1}
for _ in range(n - 1):
now = heappop(q)
for i in [2, 3, 5]:
if now * i not in vis:
vis.add(now * i)
heappush(q, now * i)
return heappop(q)