Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
M, changed to a single while loop just in case, though these while loops had O(sqrt(n)). After several attemts and combining factorials list with math function I got easy random tests and passed lol
Oh, yes I know why. Your solution has a nested while loop(a while loop inside of another while loop.) That's O(n^2) time complexity, but O(n) time complexity won't time out.
Yeah, but I have tried to create a list of factorials from 0 to 1250, this should be enough for n and k ranges I see in logs. However, I get run out of time when find factorials with built-in math module function (and, what is more strange, I get is still, with getting factorials for o(1))
I have some improvement in my mind, might help :)
That's not the problem: you can't create a list of all the facatorials. There is a module called
from math import factorial
. Also, your solution should pass, it's just that list index out of range.This comment is hidden because it contains spoiler information about the solution
In the task it is said k <= 100, but it can be up to 1000. Not clear :(