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.
Anyways. Any fun java katas?
That escalated quickly O_o
I think RamProg died
But I can, because it's a valid test case. I just wish edge cases like that existed (if this kata wasn't ancient, they would).
No, they won't. Only flawed solutions similar to yours will fail. The description and constraints are pretty clear, so there is nothing to "make up" to make this solution fail.
It's not random stuff though. It could've been in the tests as it's a valid case.
I agree, this is not the most efficient code but it's still clever.
It's still O(n), it's not that big of a deal.
"Wrong" doesn't mean "unreadable" or "not performant", it simply means incorrect. Take an example like
['n', 'n', 'n', 'n', 'e', 'e', ...]
(fill with'nnss'
, for example): your code treats the first section as if you reached the starting point. Clearly that's wrong.meanwhile, your own solution is outright wrong x)