Given is an array
The task is to compute, for each element in the list, its distance from the end of the
list, i.e. to produce an array
S
that represents the successors in a linked list:
a list 2 -> 3 -> 0 -> 4 -> 5 -> 1
is represented by an
array
i |
0 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|---|
S[i] |
4 | 2 | 3 | 0 | 5 | 1 |
R
:
i |
0 | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|---|
R[i] |
3 | 0 | 5 | 4 | 2 | 1 |