Array $P$ of length $n$ is a permutations of $\{0, ..., n-1\}$
Write a code, which would in $O(n)$ create an array $R$ of length $n$, so for values $x_i, x_j \in P$, $R[x_i] < R[x_j]$ if $x_i$ is on the left of $x_j$ ($i<j$).
This is a algorithmization problem that's recurring in the final's test each year and I'm stuck with it for weeks. I know that I'm supposed to show my work before asking here, but I didn't know how to start.
Could you at least point me to the right direction? What technique do I use, dynamic programming? Is this a problem for a specific algorithm?