human
Check if the given array is same as its inverse permutation | Function to check if the inverse permutation of the given array is same as the original array.
Stores the inverse permutation.
Generate the inverse permutation.
Check if the inverse permutation is same as the given array.
Driver code"
Solution in Python:
assistant
#Here is code to check if the given array is same as its inverse permutation and the other steps required.
 def inverseEqual ( arr , n ) :
	brr = [ 0 ] * n
	for i in range ( n ) :
		present_index = arr [ i ] - 1
		brr [ present_index ] = i + 1
	for i in range ( n ) :
		if arr [ i ] != brr [ i ] :
			print ( " NO " )
			return
	print ( " YES " )
n = 4
arr = [ 1 , 4 , 3 , 2 ]
inverseEqual ( arr , n )