# Finite Series Modification Help

I have a vector of say 8 numbers $x_1$ = [0 0 0 0 0 0 0 0].

I have information LEFT = [6L 2L] which means the the 6 most leftmost elements are to increase by 1, and then the 2 leftmost elements are to increase again by 1. Now $x_2$ = [2 2 1 1 1 1 0 0].

Also I have the information RIGHT = [7R 5R 3R 1R] which modifies the vector $x_2$ for the rightmost values giving the vector $x_3$ = [2 3 2 3 3 4 3 4].

Now as the order of the final answer is irrelevant I can represent the final series $x_3$ equivalently in descending order as $x_e$ = [4 4 3 3 3 3 2 2]. This means I could have used the equivalent modifying operations EQUIV = [8L 8L 6L 2L] directly on $x_1$.

My question is, how can I most efficiantly using LEFT and RIGHT and knowing the length of $x_1$, find EQUIV?

-
 Where did $x_e$ come from? – J. M. May 10 '11 at 11:11 $x_e$ is just $x_3$ sorted in descending order. – Projectile Fish May 10 '11 at 11:17 What do you mean by 'most efficiently'? Is the case you worked out a particular case of a more general process? – Weltschmerz May 10 '11 at 13:01 By most efficiently I mean using the least number of computational operations. Ideally I would like to work out EQUIV without having to explicitly write out the vector and add to it as I did in this example. The vector could be of any size, and the number of modifications could be any number too. – Projectile Fish May 10 '11 at 13:04