首页 > TAG信息列表 > leetcode264

leetcode264-丑数 II

丑数 II 优先队列 维护一个优先队列。先取出最小的数字,将其乘以2、3、5,如果发现没有重复的话就装入优先队列中,需要用到set进行去重。 class Solution { public int nthUglyNumber(int n) { Set<Long> set = new HashSet<>(); PriorityQueue<Long> queue = n