Ad
  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Hey RnNn, your advice really helped me. Thanks for that!

  • Default User Avatar

    Try to think of the easiest way to go from the first index of the output(answer) array which is equal to the total of all of the elements of the input array together => to the next index of the output(answer) array which is the total of all the elements of the input array except for the first element of the input array => to the next index ... also try to avoid moving more than one element during each iteration of a loop such as unshift. If you'd like to try something besides a traditional for loop, there are a couple of array methods that can be used for this problem.
    I want to add a little more info but I don't want to go from just helpful(hopefully) to spoiling. Let me know if this wasn't quite enough and I'll try to add more.

  • Default User Avatar

    Hi @shaun112345 , the kata just got approved today so maybe you "slipped through" as the final tests were being confirmed!

    In the final version, O(n^2) will fail as there are 10 tests with n = 40_000.

    I've re-run your O(n^2) solution and it does in fact fail (timeout) now that the tests are finalized.

    To answer your question, therefore, we are aiming for an O(n) solution! Congrats on the free points if you don't want to re-try, but if you want to find the answer then have fun finding the O(n) solution.

  • Custom User Avatar

    This kata has multiple issues and has been retired for some reason...

  • Default User Avatar
  • Default User Avatar

    @thekrocker I advise you to think more about the output, than the input.
    This is a performance kata, so the obvious solution works, but the test cases are rigged to get you timed out.
    Try to look for a less performance consuming way of doing it. (generally less loops)

  • Default User Avatar

    @Avanta, can you give more tips? I'm stuck, i tried Do while, for loop. I even learned about Big O Notation. But still can't figure it out.

  • Custom User Avatar

    I'm getting the same issue. I pass all the tests, but when ATTEMPT is clicked, I get the execution timeout.

  • Custom User Avatar

    No need to overcomplicate it :)

    What does the sum of each part represent?

  • Custom User Avatar
  • Default User Avatar

    suggestion: print it