Ad
  • Custom User Avatar

    @ozann This function is extremely slow even for inputs of 30,000 (20.3s on my computer).
    The language has little to do with it. This same thing coded in C would be thousands of times slower than a good Python solution even for an array of 30,000 elements.

  • Custom User Avatar

    Problem description doesn't mention a time constraint nor does it say the program should be "efficient". There's a simple task, and this is the most hassle-free, readable, and Pythonic way of attaining it. If you care so much about performance, you should stop programming in Python altogether.

  • Custom User Avatar

    Such bad code, only noobs will vote this

  • Custom User Avatar

    it's sad to see that this O(n^2) program is at top. My solution is way better using prefix sum technique. which is O(n).
    Look's like Codewar's feature is broken! learners shouln't vote ... less no. of lines doesn't mean good code.