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.
For simplicity only. In real use it is obvious to use
.lower()
method. Even additional checks for digits and special charasters.is there a reason why you didn't use .lower() function ?
it's O(n) too (with n the length of the sliced section)
yes
to avoid problem in first case the simplest way is make copy argument??
Thank you for taking the time to answer my questions!
The problem about mutating the list is that if the same instance of the list is used outside of the function, the other function will see the modified list. That can generate strange and unpredictable behavior outside of the present function. Said like that, you could not see the problem... So let me give you a concrete (it happened to me! ;) ) example: 5 kyu, I was working on a kata, and I was mutating the list. All worked fine with the fixed tests, but in the random tests, that went realy wrong. After the execution of my function, the list was empty. And after this execution, the code was executing the reference solution, using the same list object (same instance, so). And that list being empty....... You see what I mean. ;) So, to avoid unpredictible troubles, it's good practice to avoid mutations of arguments when possible. Work with a copy, mutate the copy (for example)
"O(N)" talks about the "time complexity" of the algorithm. It would be too complicate to really elaborate here if you do not know the concept. You can google it, you should find easily things about that. The general idea is that, when you have 1 loop, you have O(N), if you have a loop inside that first loop, it's O(N^2), ... (simple example, it might be far more complicate than that). And sometimes, the inner loop is hidden by another function. Here, by removing an element in the middle of the list, python has to move all the next elements one step backward. Here is the inner (hidden) loop that makes this solution O(N^2).
Cheers
Could you explain what you said further?
I'm not familiar with 'mutates the argument', and your second bullet escapes me completely.
This solution is actually very BAD practice!
You shouldn't delete elements of your array:
Very well done. I tried to use for loops to my detriment. I'll have to keep this in mind for similar problems.
This comment is hidden because it contains spoiler information about the solution