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.
This comment is hidden because it contains spoiler information about the solution
Hey RnNn, your advice really helped me. Thanks for that!
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.
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.
This kata has multiple issues and has been retired for some reason...
KROQ?
@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)
@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.
I'm getting the same issue. I pass all the tests, but when ATTEMPT is clicked, I get the execution timeout.
No need to overcomplicate it :)
What does the sum of each part represent?
https://docs.codewars.com/training/troubleshooting/#print-input
suggestion: print it