human
Give me a code to check whether ( i , j ) exists such that arr [ i ] != arr [ j ] and arr [ arr [ i ] ] is equal to arr [ arr [ j ] ] and the other steps required given the following:
Check whether ( i , j ) exists such that arr [ i ] != arr [ j ] and arr [ arr [ i ] ] is equal to arr [ arr [ j ] ] | Function that will tell whether such Indices present or Not ..
Checking 1 st condition i . e whether Arr [ i ] equal to Arr [ j ] or not.
Checking 2 nd condition i . e whether Arr [ Arr [ i ] ] equal to Arr [ Arr [ j ] ] or not ..
Driver Code.
Calling function ."
Solution in Python:
assistant
#Here is code to check whether ( i , j ) exists such that arr [ i ] != arr [ j ] and arr [ arr [ i ] ] is equal to arr [ arr [ j ] ] and the other steps required.
 def checkIndices ( Arr , N ) :
	for i in range ( N - 1 ) :
		for j in range ( i + 1 , N ) :
			if ( Arr [ i ] != Arr [ j ] ) :
				if ( Arr [ Arr [ i ] - 1 ] == Arr [ Arr [ j ] - 1 ] ) :
					return True
	return False
if __name__ == " _ _ main _ _ " :
	Arr = [ 3 , 2 , 1 , 1 , 4 ]
	N = len ( Arr )
	if checkIndices ( Arr , N ) :
		print ( " Yes " )
	else :
		print ( " No " )