Given an array A of size n of integers in the range from 1 to n, we need to find the inverse permutation of that array.
Inverse Permutation is a permutation which you will get by inserting position of an element at the position specified by the element value in the array. For better understanding, consider the following example:
Suppose we found element 4 at position 3 in an array, then in reverse permutation, we insert 3 (position of element 4 in the array) in position 4 (element value).
 
Example 1:
Input:
N = 4
Arr[] = {1, 4, 3, 2}
Output:
1 4 3 2
Explanation:
For element 1 we insert position of 1 from
arr1 i.e 1 at position 1 in arr2. For element
4 in arr1, we insert 2 from arr1 at position
4 in arr2. Similarly, for element 2 in arr1,
we insert position of 2 i.e 4 in arr2.
Example 2:
Input:
N = 5
Arr[] = {2, 3, 4, 5, 1}
Output:
5 1 2 3 4
Explanation:
As index 1 has value 2 so 1 will b 
placed at index 2, similarly 2 has
3 so 2 will be placed at index 3
similarly 3 has 4 so placed at 4,
4 has 5 so 4 placed at 5 and 5 
has 1 so placed at index 1. 
 
Your Task:  
You don't need to read input or print anything. Your task is to complete the function inversePermutation() which takes the array Arr[] and its size N as inputs and returns the vector array after performing inverse permutation on Arr.
 
Expected Time Complexity: O(N)
Expected Auxiliary Space: O(N)
 
Constraints:
1 ≤ N ≤ 10^{5}
1 ≤ A[i] ≤ N
Note: Array should contain unique elements and should
  have all elements from 1 to N.

Source: geeksforgeeks | Difficulty: EASY
Tags: Data structures

Starter code: #User function Template for python3



def inversePermutation (arr, n) : 

    #Complete the function



Solutions:
def inversePermutation(arr, n):
	a = [0] * n
	for i in range(n):
		a[arr[i] - 1] = i + 1
	return a


def inversePermutation(arr, n):
	l = [0] * n
	for i in range(n):
		l[arr[i] - 1] = i + 1
	return l


def inversePermutation(arr, n):
	c = 1
	a = [0] * n
	for i in arr:
		a[i - 1] = c
		c += 1
	return a


def inversePermutation(arr, n):
	n = len(arr)
	B = [0] * n
	for i in range(n):
		B[arr[i] - 1] = i + 1
	return B


def inversePermutation(arr, n):
	ans = [0] * n
	for i in range(0, n):
		ans[arr[i] - 1] = i + 1
	return ans


def inversePermutation(arr, n):
	ar = [0] * n
	for i in range(n):
		ar[arr[i] - 1] = i + 1
	return ar


def inversePermutation(arr, n):
	brr = [0] * n
	for (i, item) in enumerate(arr):
		brr[item - 1] = i + 1
	return brr


def inversePermutation(arr, n):
	res = [0] * n
	j = 0
	for i in arr:
		res[i - 1] = j + 1
		j += 1
	return res


def inversePermutation(arr, n):
	p = [0] * n
	for index in range(n):
		p[arr[index] - 1] = index + 1
	return p


def inversePermutation(arr, n):
	res = [0] * n
	for i in range(n):
		res[arr[i] - 1] = i + 1
	return res


def inversePermutation(arr, n):
	li = [0] * n
	for i in range(n):
		li[arr[i] - 1] = i + 1
	return li


def inversePermutation(arr, n):
	arr2 = [0] * n
	for i in range(n):
		arr2[arr[i] - 1] = i + 1
	return arr2


def inversePermutation(arr, n):
	b = [0] * n
	for i in range(n):
		b[arr[i] - 1] = i + 1
	return b


from collections import Counter

def inversePermutation(arr, n):
	a = []
	for i in range(1, n + 1):
		a.append(i)
	d = dict(zip(arr, a))
	ans = []
	for i in a:
		ans.append(d[i])
	return ans


def inversePermutation(arr, n):
	l = [0] * n
	i = 0
	while i < n:
		if arr[i] == i + 1:
			l[i] = i + 1
			i += 1
		else:
			m = arr[i]
			l[m - 1] = i + 1
			i += 1
	arr[:] = l
	return arr


def inversePermutation(arr, n):
	x = []
	for i in range(n + 1):
		x.append(0)
	for i in range(1, n + 1):
		k = arr[i - 1]
		x[k] = i
	x.remove(x[0])
	return x


def inversePermutation(arr, n):
	res = [None] * n
	for i in range(n):
		res[arr[i] - 1] = i + 1
	return res
	print(res)


def inversePermutation(arr, n):
	arr2 = [0] * n
	index = 0
	while index != n:
		value = arr[index]
		arr2[value - 1] = index + 1
		index += 1
	return arr2


def inversePermutation(arr, n):
	arr2 = []
	no = n
	while no != 0:
		arr2.append(0)
		no -= 1
	index = 0
	while index != n:
		value = arr[index]
		arr2[value - 1] = index + 1
		index += 1
	return arr2


def inversePermutation(a, n):
	b = [0] * n
	for i in range(n):
		b[a[i] - 1] = i + 1
	return b


def inversePermutation(arr, n):
	d = {}
	for i in range(1, n + 1):
		d[arr[i - 1]] = i
	ans = []
	for i in range(1, n + 1):
		ans.append(d[i])
	return ans


def inversePermutation(arr, n):
	lst = [0] * (n + 1)
	for i in range(n):
		lst[arr[i]] = i + 1
	return lst[1:]


def inversePermutation(arr, n):
	newarr = arr.copy()
	for i in range(len(arr)):
		newarr[arr[i] - 1] = i + 1
	return newarr


def inversePermutation(arr, n):
	count = 0
	brr = [None] * n
	for i in range(n):
		count += 1
		brr[arr[i] - 1] = count
	return brr


def inversePermutation(arr, n):
	lis = [0] * n
	for i in range(n):
		lis[arr[i] - 1] = i + 1
	return lis


def inversePermutation(arr, n):
	final = [0] * n
	for i in range(n):
		final[arr[i] - 1] = i + 1
	return final


def inversePermutation(a, n):
	ans = [0] * n
	for i in range(n):
		ans[a[i] - 1] = i + 1
	return ans


def inversePermutation(arr, n):
	j = 0
	li = [0] * n
	for i in arr:
		li[i - 1] = j + 1
		j += 1
	return li


def inversePermutation(arr, n):
	result = [None] * n
	for i in range(n):
		index = i
		value = arr[i]
		result[value - 1] = index + 1
	return result


def inversePermutation(arr, n):
	d = {}
	for i in range(0, n):
		d[arr[i]] = i + 1
	d = dict(map(reversed, d.items()))
	arr = sorted(d, key=d.get)
	return arr


def inversePermutation(arr, n):
	a = sorted(arr)
	l = [0] * n
	for x in range(n):
		l[arr[x] - 1] = x + 1
	return l


def inversePermutation(arr, n):
	deq = [0 for i in range(n)]
	count = 0
	for i in range(n):
		deq[arr[i] - 1] = i + 1
	return deq


def inversePermutation(arr, n):
	arr1 = [0] * n
	for i in range(n):
		arr1[arr[i] - 1] = i + 1
	return arr1


def inversePermutation(arr, n):
	newArr = [0] * n
	for i in range(1, n + 1):
		newArr[arr[i - 1] - 1] = i
	return newArr


def inversePermutation(arr, n):
	l = list((i for i in range(n)))
	for i in range(n):
		l[arr[i] - 1] = i + 1
	return l


def inversePermutation(arr, n):
	j = 0
	l1 = [0] * n
	for i in arr:
		l1[i - 1] = j + 1
		j += 1
	return l1


def inversePermutation(arr, n):
	l1 = [0] * n
	for i in range(n):
		l1[arr[i] - 1] = i + 1
	return l1


def inversePermutation(arr, n):
	a = [0] * n
	j = 0
	for i in arr:
		a[i - 1] = j + 1
		j += 1
	return a


def inversePermutation(arr, n):
	z = [0] * n
	j = 0
	for i in arr:
		z[i - 1] = j + 1
		j += 1
	return z


def inversePermutation(arr, n):
	j = 0
	l = [0] * n
	for i in arr:
		l[i - 1] = j + 1
		j += 1
	return l


def inversePermutation(arr, n):
	temp = [0] * n
	for i in range(0, n):
		temp[arr[i] - 1] = i + 1
	return temp


def inversePermutation(arr, n):
	list1 = [0] * n
	for i in range(0, n):
		index = arr[i]
		list1[index - 1] = i + 1
	return list1


def inversePermutation(arr, n):
	k = 0
	position = [0] * n
	for i in arr:
		position[i - 1] = k + 1
		k += 1
	return position


def inversePermutation(arr, n):
	ans = [None] * n
	for i in range(n):
		data = arr[i]
		index = i + 1
		ans[data - 1] = index
	return ans


def inversePermutation(arr, n):
	j = 0
	l1 = [0] * n
	for i in arr:
		l1[i - 1] = j + 1
		j += 1
	return l1
for _ in range(0, int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	ans = inversePermutation(arr, n)
	print(*ans)


def inversePermutation(a, n):
	b = [0 for i in range(n)]
	for i in range(1, n + 1):
		b[a[i - 1] - 1] = i
	return b
for _ in range(0, int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	ans = inversePermutation(arr, n)
	print(*ans)


def inversePermutation(arr, n):
	l = [0 for _ in range(n)]
	for i in range(len(arr)):
		l[arr[i] - 1] = i + 1
	return l
for _ in range(0, int(input())):
	n = int(input())
	arr = list(map(int, input().strip().split()))
	ans = inversePermutation(arr, n)
	print(*ans)