human
Find the length of largest subarray in which all elements are Autobiographical Numbers | Function to check number is autobiographical.
Convert integer to string.
Iterate for every digit to check for their total count.
Check occurrence of every number and count them.
Check if any position mismatches with total count them return with false else continue with loop.
Function to return the length of the largest subarray whose every element is a autobiographical number.
Utility function which checks every element of array for autobiographical number.
Check if element arr [ i ] is an autobiographical number.
Increment the current length.
Update max_length value.
Return the final result.
Driver code"
Solution in Python:
assistant
#Here is code to find the length of largest subarray in which all elements are Autobiographical Numbers and the other steps required.
 def isAutoBiographyNum ( number ) :
	count = 0 ;
	NUM = str ( number ) ;
	size = len ( NUM ) ;
	for i in range ( size ) :
		position = ord ( NUM [ i ] ) - ord ( '0' ) ;
		count = 0 ;
		for j in range ( size ) :
			digit = ord ( NUM [ j ] ) - ord ( '0' ) ;
			if ( digit == i ) :
				count += 1 ;
		if ( position != count ) :
			return False ;
	return True ;
def checkArray ( arr , n ) :
	current_length = 0 ;
	max_length = 0 ;
	for i in range ( n ) :
		if ( isAutoBiographyNum ( arr [ i ] ) ) :
			current_length += 1 ;
		else :
			current_length = 0 ;
		max_length = max ( max_length , current_length ) ;
	return max_length ;
if __name__ == " _ _ main _ _ " :
	arr = [ 21200 , 1 , 1303 , 1210 , 2020 ] ;
	n = len ( arr ) ;
	print ( checkArray ( arr , n ) ) ;