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.
I love this solution! I'm kinda obsessed with reduce() and I've lost my ability to see other solutions,if I can use reduce(). How to overcome that >< ???
The best one for sure.
good to know people with great cleverness!
Your solution is not displayed completely. Please, train this kata again and include the other foo's into scramble()
Performance and simple!
So why do you map the characters in the first string, which can potentially be very big, than doing it on the 2nd one ? It helps with performance in average cases.
str2 will aways be shorter than str1 otherwise the function returns false
e.g
str1 has 1million characters
str2 has 5 characters
str2 can be made out from the first 10 characters of str1
you have just saved a lot of space if you also keep track of when keys in the map reach 0.
Check my solution for how to get max performance for this.
This comment is hidden because it contains spoiler information about the solution
You should use the newer ES6 version
for (let ch of str1)
because that will not iterate over inherited properties.在计算大量数据时,还是这种方法靠谱。
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Good thing that you return a new array insted of mutating the given one !
Great solution!
it returns true even for strings which are not JoJo, for example "jorg aajobb".
This comment is hidden because it contains spoiler information about the solution
Loading more items...