Ad
  • Custom User Avatar

    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 of li.pop(0)?

  • Custom User Avatar

    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 of pop 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.

  • Custom User Avatar

    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.

  • Custom User Avatar

    general tip:

    your environment isn't CW's environment

    • maybe you processor is facter than the ones of the servers
    • in python, there are problems of performances with random value generation (related to the docker itself), meaning that'll slow even more the tests here.

    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 ;)

  • Custom User Avatar

    You could also find some hints in comments below, for example this one: https://www.codewars.com/kata/5ce399e0047a45001c853c2b/discuss#5f29266f664ae7001042a4d7

  • Custom User Avatar

    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.