File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -245,11 +245,11 @@ class Solution {
245
245
var vis = Set < Int64 > ()
246
246
var pq = PriorityQueue< Int64 > ()
247
247
let factors: [Int64 ] = [2 , 3 , 5 ]
248
-
248
+
249
249
pq.push (1 )
250
250
vis.insert (1 )
251
251
var ans: Int64 = 0
252
-
252
+
253
253
for _ in 0 ..< n {
254
254
ans = pq.pop ()!
255
255
for factor in factors {
@@ -259,23 +259,23 @@ class Solution {
259
259
}
260
260
}
261
261
}
262
-
262
+
263
263
return Int (ans)
264
264
}
265
265
}
266
266
267
267
struct PriorityQueue <T : Comparable > {
268
268
private var heap: [T] = []
269
-
269
+
270
270
var isEmpty: Bool {
271
271
return heap.isEmpty
272
272
}
273
-
273
+
274
274
mutating func push (_ element : T) {
275
275
heap.append (element)
276
276
heapifyUp (from : heap.count - 1 )
277
277
}
278
-
278
+
279
279
mutating func pop () -> T? {
280
280
guard ! heap.isEmpty else {
281
281
return nil
@@ -288,7 +288,7 @@ struct PriorityQueue<T: Comparable> {
288
288
heapifyDown (from : 0 )
289
289
return value
290
290
}
291
-
291
+
292
292
private mutating func heapifyUp (from index : Int ) {
293
293
var index = index
294
294
let element = heap[index]
@@ -302,7 +302,7 @@ struct PriorityQueue<T: Comparable> {
302
302
}
303
303
heap[index] = element
304
304
}
305
-
305
+
306
306
private mutating func heapifyDown (from index : Int ) {
307
307
var index = index
308
308
let element = heap[index]
You can’t perform that action at this time.
0 commit comments