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 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.
This comment is hidden because it contains spoiler information about the solution
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.where n is always 10 and thus it's O(1)
This comment is hidden because it contains spoiler information about the solution
meanwhile, your own solution is outright wrong x)
Awful
This comment is hidden because it contains spoiler information about the solution
Can't understand why some people voted this is best practice when it's the exact opposite. Unreadable code with a lot of bloating comments.
This is fun to do and very clever, but such unreadable code.