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.
@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.
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.
Such bad code, only noobs will vote this
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.