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.
This comment is hidden because it contains spoiler information about the solution
how is it faster ?
The fact that this question even gets asked is an indication that this solution is less than ideal.
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?
This comment is hidden because it contains spoiler information about the solution
Yep, it's somehow faster.
This comment is hidden because it contains spoiler information about the solution
The reason is that if we have j and i being equal at any point in our comparison, they are both going to point to the same index of the string. Say we have str = "A". Using j = 0 in the second loop will return true, which is clearly not what we want.
The reason is that if we have j and i being equal at any point in our comparison, they are both going to point to the same index of the string. Say we have str = "A". Using j = 0 in the second loop will return true, which is clearly not what we want.
The reason is that if we have j and i being equal at any point in our comparison, they are both going to point to the same index of the string. Say we have str = "A". Using j = 0 in the second loop will return true, which is clearly not what we want.
The reason is that if we have j and i being equal at any point in our comparison, they are both going to point to the same index of the string. Say we have str = "A". Using j = 0 in the second loop will return true, which is clearly not what we want.
The reason is that if we have j and i being equal at any point in our comparison, they are both going to point to the same index of the string. Say we have str = "A". Using j = 0 in the second loop will return true, which is clearly not what we want.
This comment is hidden because it contains spoiler information about the solution
Thank you man
Because it doesn't need to test against itself. And it no longer needs to be compared once it's been tested.
Loading more items...