Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
由于我们已经注册了名为 result ,我相信我们不必有堆栈来将结果保存在内存中,我们只需要 1 个内存空间。我在大 O(1) 中假设正确的 s(n) 也是如此。
The space complexity is given by the number of bits of the result. Using Stirling's approximation, log n! is O(n log n).
log n!
O(n log n)