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.
if(true) return true;
else return false;
vibes
Isn't it possibly O(n^2) since there are nested loops?
This comment is hidden because it contains spoiler information about the solution
Amazing amazing! I appreciate this soltion to help me revise Try Except! :)
OmG 😢😢.
that was a bit similar to mine, but i should have thought of that.
anyways i dont know how i succeded😅😅
two unnecessary parentheses showing bad knowledge of the operators' precedence
Why is this best practice?
It works, surely the problem is that you're trying to print the array directly, but print method doesn't prints the array as it prints Lists, so you have to print it with a for or something
this solution doesn't work for me.
when i input this -> digitize(2425342)
i got this output -> [I@3941a79c
I wonder, what i missing...
lol
yes it would
i agree with what has been said and ill keep that in mind next time. But also to make it faster, could you also add a break right after you add the element into the set. Because elements in a1 needs to be a substring of at least one of the elements in a2, wouldnt it be best to cut off the for-loop and go on with the next word in a1?
im new to coding and im curious, i like to make my code as optimal as possible :)
first try - did well , yet still learning how this env works.
But if the function gets called like last("hi", "bye") this would return "e" and from what I understood this should return "bye" with that input.
It seems the kata needs more tests or clarify that in the instructions.
Building up on the previous comment... Look at: https://wiki.python.org/moin/TimeComplexity
x in list
has O(n) complexity, whilex in set
is O(1) [assuming collisions are unlikely].So, considering
array1
andarray2
have lengthn
andm
, this code usinglist
has complexityO(n * n * m + n * log n)
which can be simplified asO(n**2 * m)
, while usingset
can reduce it toO(n * m + n * log n)
.Loading more items...