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 you split for example "a__b" (double space instead of underscores) into a list, it will result in ["a", "", "b"].
When you join it later, there will be one space between "a" and the empty string "" - and another space between the empty string and "b". Therefore you end up keeping the double space like in the original string.
Your solution is not far from the above.
I'm sorry for my bad English, but in order to solve this kata, I needed an additional condition, because the tests did not pass, and everything went without it...
Strange tests, the second time passed without a condition :)
https://docs.python.org/3/library/stdtypes.html#str.split
How does this account for string casing, i.e uppercase, lowercase?
OP's solution is better imo. More readable, and doesn't add clutter (Not that yours does)
Haha I like that
This comment is hidden because it contains spoiler information about the solution
As someone whose last math class was before 9/11, I sometimes feel this way, but not this time!
This was clearly explained, with great examples.
Plus, it was an actual coding challenge, not some Math-trick riddle that's useless in real life.
behind the scenes, the JS interpreter will have to:
Why does using regex make it slow?
It uses regex, so answer is "no".
But it's slower
How about mine? What's the time and space complexity
Well, one call to match is performed in O(N) and you cannot solve the problem faster.
But it also allocates extra O(N) memory only to take the length of the array[-ish structure] later.
TIME = O(N), optimal
MEM = O(N), non-optimal, O(1) is possible.
Loading more items...