力扣 264. 丑数 II python AC
堆
from heapq import heappop, heappushclass 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)