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.
Your solution has to compile the regex for every element in the array. You could compile it first to eliminate that overhead, but I suspect it would still be slower as it involves multiple calls to match instead of a single call. str.join and re.findall are both very efficient operations.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Python 3.8 adds the walrus operator which allows you to assign the result of the sum in the if statement to a variable and reuse it later in the comprehension.
You might find this article on the Python wiki useful:
https://wiki.python.org/moin/TimeComplexity
This comment is hidden because it contains spoiler information about the solution
I read that as stating s1 and s2 will only include letters from a to z. ie. don't worry about non-alphabetic characters.
This comment is hidden because it contains spoiler information about the solution
Thanks, that fixes the issue for me. I'm not familiar with lexicographical as a term and in the context of the tests presented in the description, I interpreted it as the order they appear in the text. Perhaps saying alphabetical order would be more clear?
For the test of "dcbadcba", the test says "a" is the correct answer. My reading of the instructions is that a and d have the same values (4), but that d has precedence since it comes earlier in the string and that therefore the answer should be d.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Loading more items...