Angga
Hallo everyone
I am stuck doing my task.
Here are the tasks:
Programming Quiz: Pattern Recognition
Tasks:
Write a function that takes a list of integers as input and returns a new list where each element is the sum of all the elements in the original list that comes after it (including itself).
Examples:
Input: [2, 3, 8]
Output: [13, 10, 2]
Input: [6, 2, 3]
Output: [11, 9, 6]
Input: [4, 7, 2, 8, 6]
Output: [27, 25, 17, 10, 4]
Constraints:
The input list will contain at least one integer.
This is the code I have created: https://pastecode.io/s/2weq3pxg
The problem is when inputting: [4, 7, 2, 8, 6]
The output: [27,20,25,19,4]
Which is not appropriate to the question.
Please advise and guide me, I have a mistake / misguided thinking in making the algorithm where?🙏🏻🙏🏻🙏🏻
Thank you very much🙏🏻