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.
way too complicated for the top answer to this tricky kata! I'm pretty proud of mine.
honestly i dont know
it's good :)
Good point, calling the object "arr" confused me.
it's kinda slow, mine is faster
A faster approach timed me out, so I guess you cannot get away with this anymore...
can someone please explain?? I don't understand
Checking if there is a key for the character with each character is not good for performance at all. It would be better to hardcode an object with all the values equal to 0, saving an if-statement in each iteration.
@Firefly2002 you definitely had the best, more performant and readable solution. I learned a lot from it. Thanks.
Is it always the case that a for loop is more performant than a reduce that does the same thing?
They don't have the same mistake. This is the solution of only one person. The others just copied it and submitted it as their own. It's "occurrences".
Yes, but are you sure the 20% performance overhead is really that important except in a very handful cases? ;-)
"you just have to do some maths to figure out what that value is."
lol you are literally the most annoying person.
obviously when i wrote this 7 months ago i was trying to figure out why you couldn't just move the decrement to after without changing the 0 to a 1. thanks for the pointer though bruh, real helpful,
It certainly isn't "best practice". And like the others have pointed out, this is not a performant solution. Probably doesn't warrant a downvote though.
What's more interesting is the fact that 4 separate people had the exact same mistake...
Or just
> 1
.Putting increments or decrements before or after don't really matter in these instances since you are comparing to a fixed value. You just have to do some maths to figure out what that value is.
Loading more items...