From fcf65410243dc5db7ad2b75c3a5012ecc26b72ea Mon Sep 17 00:00:00 2001 From: kamyu Date: Thu, 29 Mar 2018 13:56:30 +0800 Subject: [PATCH] Update super-ugly-number.cpp --- C++/super-ugly-number.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/C++/super-ugly-number.cpp b/C++/super-ugly-number.cpp index 3e786e2b0..67097c6fb 100644 --- a/C++/super-ugly-number.cpp +++ b/C++/super-ugly-number.cpp @@ -1,4 +1,4 @@ -// Time: O(n * logk) ~ O(n * k) +// Time: O(n * k) // Space: O(n + k) // Heap solution. (308ms) @@ -17,7 +17,7 @@ class Solution { tie(uglies[i], k) = heap.top(); heap.pop(); ugly_by_last_prime[i] = k; - while (ugly_by_last_prime[++idx[k]] > k); // worst time: O(k) + while (ugly_by_last_prime[++idx[k]] > k); // average time: O(k) heap.emplace(uglies[idx[k]] * primes[k], k); } return uglies[n - 1];