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 really like your O(1) solution... unclear how you solved that nominal?
No matter how much you like this solution, it's bad. If you have considerations related to performance, then you shoud be concerned by the fact it contains a loop. This problem does not require a loop to solve it. Solution with loop requires many operations, and is slow. Solutions without loop always perform like a dozen or two of of operations total, no matter how large is
n
.