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.
Very interesting oneliner, funny kata.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Yet, this mutation is quite harmless for it adds an additional element and it doesn't actually modify any existing data. In that specific case, I would assume that adding data is actualy the requirement rather than not.
Absolutely true, I was searching for linear extrapolation furmula, before I took a look here.
I can't see how it uses more sum() calls that the regular loop solutions provided.
This comment is hidden because it contains spoiler information about the solution
Indeed, it is much simpler than it seemed at first, I managed to solve it, thanks for the reply.
Hi - your current approach is basically a brute force search (it is trying all possible combinations of subarrays effectively), so it will indeed get the correct solution.
However, the large random tests involve
lists
with up to50,000
elements - if you perform the brute force approach you will therefore need to perform50,000 ** 2
operations approximately, for each test, which is a huge number.That's why you are timing out; your solution is correct, but inefficient.
To answer your question for advice about this; you cannot really speed up your current brute force approach - instead, you need to reduce the time complexity from O(n^2) to something less than O(n^2).
I have the same problem as @eshis with python, everything seems to work excluding last random test.