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 don't think it needs O(n^2) since the smiley array size is constant. So it would be O(n) still.
Idk how this is 5kyu but was a nice problem to solve...
EZ
I did something similar. All this people are using RegExps and prototype functions and increasing their time complexity. Also, with this method (by using an object instead of an array for the lookup table) you get O(1) lookup time for the mapped out characters.
The only downside with this is that it will use O(n) space. But that is how code works, gotta sacrifice space for time and vice versa.