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.
Could you explain what's happening here? It looks really clever, but I have a hard time understanding what's going on.
This is a clever solution, but it's rather inefficient:
indexOf
(andlastIndexOf
) have a performance that's linear in the input (O(n)
), meaning that the entire solution has a complexity ofO(n^2)
(i.e. worst case runtime is determined by the square of the input size). There areO(n)
solutions, i.e. runtime is linear with input size.