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.
sample
tests.This comment is hidden because it contains spoiler information about the solution
Solved it bro :} Had to change my approach a little bit but at the end it was all worth it
You been unable to make your code work is not a kata issue. Please read this
Either solve it or forfeit it and see how to solve it.
Who is preparing those tests, my coding skills are not able to make this code more efficient. I mean, it is testing this code with Arrays that have 200000 items. Are you kidding me?
Popping out from front is of
O(len(li))
complexity, and this time it is entirely useless.Why don't you use
li[x]
instead ofli.pop(0)
?Due to use of
pop
, your solution is O(n^2) complexity and it's not performant enough. You need solution of O(n) complexity to pass this kata. Getting rid ofpop
and replacing it with something better should help, as some other user below had exactly the same problem (see https://www.codewars.com/kata/5ce399e0047a45001c853c2b/discuss/python#5f29e378ca407900248d73ba).Not a kata issue.
Let me repeat: range of vaules does not make any difference for this kata. you can have all 0s or all bazzillions, it does not matter. What matters is length of the input array, and not what is inside.
4s for one array on your local machine is not enough. For Python, there are 5 cases with length of 100_000, and 5 cases woth length of 150_000 (and a couple of small cases). All of these ten cases run together have to run under 12 seconds. If your solution runs 4 seconds for one case, it won't manage to run 10 cases under 12 seconds.
@Blind4Basics
Still doesnt make any sense.. they must have less than 0.1 Ghz (mathamaticly) for my code to make that bad of a result. I tested my code with 10 times more values and much bigger numbers then the actual tests do and even with value genration and printing i get 4 seconds. So how in the world should they get more than 12 seconds on a tenth of my values, that are also smaller?
general tip:
main idea to extract from this: don't rely on this kind of comparison. The only useful point of view for you is what's happening on CW.
good luck ;)
This comment is hidden because it contains spoiler information about the solution
@hobovsky This doesnt make any sense. I tested my code with randomly generated nums. 150000 nums between one hundred septenvigintillion and one hundred novemquinquagintillion. This took only 4 seconds with genrating the nums.
Basically: It works, but on the site, it doesnt.
Maybe this hint will be useful? https://www.codewars.com/kata/5ce399e0047a45001c853c2b/discuss#5f29266f664ae7001042a4d7
You could also find some hints in comments below, for example this one: https://www.codewars.com/kata/5ce399e0047a45001c853c2b/discuss#5f29266f664ae7001042a4d7
It depends on language, but values do not mattr much for this kata, array length is much more important and arrays can be long. Like, 100_000 elements.
Try to generate a couple of arrays with gradually increasing length, let's say 100 lements, 1000 elements, 10_000 and 100_000 elements and see if your solution can handle these.
In Python, there are 5 tests where max array length can go up to 150_000.
Loading more items...