Consider the following block of code.
int q[n];
for (int i = 0; i < n; i++) {
q[p[i]] = i;
}
Assume that the array p and its length n are already defined before these lines. It is known that p is a permutation of the first n non-negative integers.
You are given what array q looks like after this code is run. Can you find out what is the array p? Write your answer as a single line containing n numbers, separating them by one space.
For example, if n was 3 and q was "1 2 0", then the answer would be "2 0 1".
You have two cases to solve. Produce an answer for each of them.