Ad
  • Default User Avatar

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

  • Custom User Avatar

    Use the Round clause to round the percent_growth column.