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.
But of course some compilers would optimize it for us themselves.
This comment is hidden because it contains spoiler information about the solution
It would iterate over string two times. It's an easy solution, but strange that it's rated as best.
There is no such thing as 'O(2n)' in big O notation. There are different notations which keeps the constant multiplier before function, such as 'tilde notation', see https://www.reddit.com/r/compsci/comments/1bl0q8/tilde_notation/. But you are right this solution is quite inefficient.