313_super_ugly_number.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:Machine_Learning_Playground 作者: yao23 项目源码 文件源码
def nthSuperUglyNumber(self, n, primes):
        """
        :type n: int
        :type primes: List[int]
        :rtype: int
        """
        uglies = [1]
        merged = heapq.merge(*map(lambda p: (u*p for u in uglies), primes))
        uniqed = (u for u, _ in itertools.groupby(merged))
        map(uglies.append, itertools.islice(uniqed, n-1))
        return uglies[-1]

    # beats 85.23%
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号