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.
The fact that this question even gets asked is an indication that this solution is less than ideal.
What an es5 monstrosity
This solution has a time complexity of O(n^2), which is considered horrible.
the solution is from 8 years ago
why still using var?
why would you do that ?
Because in the second for loop we dont want to compare the same letter to itself.
Also, there is no need to compare the second letter to the first, third letter to the first and second, and so on, if youve already compared them before ever reaching to that particular letter.
i.e
[a, b, c, d , e ,a]
starting from a, you compare it to everything but itself.
when youre at b, you dont need to compare it to a since you did that already. This continues for each letter. Makes sense?
Study Big O Notation.. It's not as hard
How can I measure the O( ) of my code?
This comment is hidden because it contains spoiler information about the solution
I have just tested this code, it doesn't work for the first 2 cases.
Nested loop
this is O(n^2) not a very performant solution.
This comment is hidden because it contains spoiler information about the solution
This isn't a very performanent solution...n^2