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.
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)
This comment is hidden because it contains spoiler information about the solution
Each call to filter creates a new array in memory, resulting in O(n) space complexity in the worst case.
It's really readable code, but it's four passes through the loop
Smart approach! Why didn't I think of this
this is clever but really not a best practices
Loading more items...