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.
Swift translation
Swift translation kumited
It throws a fatalerror, as negative numbers are not in the domain of
prefix
.Constants get elimitated in big-O notation O(3*n) is equivalent to O(n).
Your solution is actually an O(n^2) solution, due to the calls of firstIndex and lastIndex for each character. My solution is O(n) as it uses only constant time operations for each character. That doesn't really matter for smal examples like this, but for longer strings for larger alphabets, it will make a difference.
That did the trick. I belive I stumbled onto that fix once before but had forgotton about it. Thanks.
OK. I've made it private, thaough for some reason it seems to be trying to run the tests under Swift 4 when I go to publish, so the tests are failing on the
Int.random(In:)
functions in the test cases, which were added after v4, and the version selector is missing, keeping me from switching it back to Swift 5.Whoops. Forgot to copy them over. Fixed.
Swift 5 translation kumited. Please review and approve if acceptable.
Swift 5 translation kumited. Please review and approve if accepable.
Swift 5 translation kumited. Please review and approve if acceptable.
Swift 5 translation kumited. Please review and approve if acceptable.
Swift translation kumited. Please review and approve if acceptable.
Swift translation kumited. Please review and approve if acceptable.
Swift translation added. Please review and approve if acceptable.
Loading more items...