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.
Are you sure you're using the specific space character given in the description? because it's not the one of the space bar of your keyboard.
The expected output is a single string with each row separated with line break.
You need to join your list.
You've answered your own question: what's wrong is, that it runs out of time.
You need to find a more efficient (faster) algorithm - currently your approach takes too long to find answers for inputs such as
n = 1000000000
.Hi and welcome to Codewars.
If you decide, each time your code doesn't work, that the problem is with the kata rather than your code, then you are going to have a bad experience!
It takes 2 seconds to think of a simple test to see that it is your solution, not the kata, that has some problems: for example try this input:
[10,-1,15]
. The correct answer is obviously24
. Your code returns10
.What would be the problem?
That's because you mutate the list you're iterating through, note the amount of 0s that your code skipped and how many pairs of 0s you have in the input.
For inputs
a1=[2,2] a2=[4]
your solution returnsTrue
, but it sohuld returnFalse
.