How to break a vector such as [9,7,6,3,4,0,1,7,3,9]
-> [[9,7,6,3],[4,1],[7,3],[9]]
-> [25,5,10,9]
?
The logic behind it is that a vector is broken into subvectors where each subsequent element is smaller than previous one(0'z are ignored), a descending sequence . When the subvectors are formed, each one is replaced with a sum of all of its elements.
[https://www.codewars.com/kata/5f8fb3c06c8f520032c1e091][1]