human
What is a code to count of subarrays whose maximum element is greater than k and the other steps required given the following:
Count of subarrays whose maximum element is greater than k | Return number of subarrays whose maximum element is less than or equal to K ..
To store count of subarrays with all elements less than or equal to k ..
Traversing the array ..
If element is greater than k , ignore ..
Counting the subarray length whose each element is less than equal to k ..
Suming number of subarray whose maximum element is less than equal to k ..
Driver code"
Solution in Python:
assistant
#Here is code to count of subarrays whose maximum element is greater than k and the other steps required.
 def countSubarray ( arr , n , k ) :
	s = 0
	i = 0
	while ( i < n ) :
		if ( arr [ i ] > k ) :
			i = i + 1
			continue
		count = 0
		while ( i < n and arr [ i ] <= k ) :
			i = i + 1
			count = count + 1
		s = s + ( ( count * ( count + 1 ) ) // 2 )
	return ( n * ( n + 1 ) // 2 - s )
arr = [ 1 , 2 , 3 ]
k = 2
n = len ( arr )
print ( countSubarray ( arr , n , k ) )