human
Give me a code to count of subarrays of size K which is a permutation of numbers from 1 to K and the other steps required given the following:
Count of subarrays of size K which is a permutation of numbers from 1 to K | Python3 program to implement the above approach.
Save index of numbers of the array.
Update min and max index with the current index and check if it 's a  valid permutation.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to count of subarrays of size K which is a permutation of numbers from 1 to K and the other steps required.
 def find_permutations ( arr ) :
	cnt = 0
	max_ind = - 1
	min_ind = 10000000 ;
	n = len ( arr )
	index_of = { }
	for i in range ( n ) :
		index_of [ arr [ i ] ] = i + 1
	for i in range ( 1 , n + 1 ) :
		max_ind = max ( max_ind , index_of [ i ] )
		min_ind = min ( min_ind , index_of [ i ] )
		if ( max_ind - min_ind + 1 == i ) :
			cnt += 1
	return cnt
if __name__ == " _ _ main _ _ " :
	nums = [ ]
	nums . append ( 2 )
	nums . append ( 3 )
	nums . append ( 1 )
	nums . append ( 5 )
	nums . append ( 4 )
	print ( find_permutations ( nums ) )