The prefix array is quite famous in the programming world. This article would discuss a variation of this scheme. This deals with the cumulative list sum till a K value, and again starts cumulation of sum from occurrence of K value. Let’s discuss certain way in which this can be performed.
Method #1 : Using Naive Method
In the naive method, we just construct the new list comprising of the the sum of prev. value of list until K and restarts the procedure once a non K value is encountered.
The original list is : [1, 3, 4, 10, 4, 5, 10, 7, 8] The computed modified new list : [1, 4, 8, 18, 22, 27, 37, 44, 52]
- Python | Value summation of key in dictionary
- Python | Selective Records Value Summation
- Python | Non-Repeating value Summation in Matrix
- Python - Index Value Summation List
- Python - Summation of float string list
- Python | Position Summation in List of Tuples
- Python | Strings length summation
- Python | Column summation in uneven sized lists
- Python | Column summation of tuples
- Python | Alternate element summation in list
- Python | Summation of list as tuple attribute
- Python | Summation of Non-Zero groups
- Python | Grouped summation of tuple list
- Python | Summation of integers in heterogenous list
- Python | Summation of dictionary list values
- Python | Pair summation of list elements
- Python | Summation of Kth Column of Tuple List
- Python - Consecutive Row summation in Matrix
- Python | Cummulative Columns summation of Records
- Python | Summation of tuples in list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.