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.
Post your code using markdown formatting and marking your post as having spoiler content so we can check what's wrong then.
O(n) should work. Is your code really O(n)?
How fast exactly the solution should be? Because I just went from O(n^2) to O(n), and it's still too slow. It didn't pass even one test more, than the initial O(n^2). I don't really know what I could improve, since O(1) is impossible.
(Python) I couldn't satisfy the time requirement after attempting this problem for hours, so I just unlocked the solutions.
I used the top rated solution and it still timed out for me after 445 tests...