Given a 1-D array called freckle
,
perform the following sequence of operations.
Step | Array |
---|---|
freckle |
2, 7, 3, 1, 0, 5 |
1. Sort the elements in descending order | 7, 5, 3, 2, 1, 0 |
2. Take their cumulative sum | 7, 12, 15, 17, 18, 18 |
3. Undo the sort from step 1 | 17, 7, 15, 18, 18, 12 |