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 to 50,000 elements - if you perform the brute force approach you will therefore need to perform 50,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).
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.
This comment is hidden because it contains spoiler information about the solution
Use the Round clause to round the percent_growth column.
This comment is hidden because it contains spoiler information about the solution