human
Check if an Array is a permutation of numbers from 1 to N | Function to check if an array represents a permutation or not.
Set to check the count of non - repeating elements.
Insert all elements in the set.
Calculating the max element.
Check if set size is equal to n.
Driver code"
Solution in Python:
 Can you provide a code to check if an Array is a permutation of numbers from 1 to N and the other steps required?
assistant
#Here is code to check if an Array is a permutation of numbers from 1 to N and the other steps required.
 def permutation ( arr , n ) :
	s = set ( )
	maxEle = 0 ;
	for i in range ( n ) :
		s . add ( arr [ i ] ) ;
		maxEle = max ( maxEle , arr [ i ] ) ;
	if ( maxEle != n ) :
		return False
	if ( len ( s ) == n ) :
		return True ;
	return False ;
if __name__ == ' _ _ main _ _ ' :
	arr = [ 1 , 2 , 5 , 3 , 2 ]
	n = len ( arr )
	if ( permutation ( arr , n ) ) :
		print ( " Yes " )
	else :
		print ( " No " )