human
Count of elements that can be deleted without disturbing the mean of the initial array | Function to find the elements which do not change the mean on removal.
To store the Sum of the array elements.
To store the initial mean.
to store the count of required elements.
Iterate over the array.
Finding the new mean.
If the new mean equals to the initial mean.
Driver code"
How can the above be solved in Python?
assistant
#Here is code to count of elements that can be deleted without disturbing the mean of the initial array and the other steps required.
 def countElements ( arr , n ) :
	Sum = 0
	for i in range ( n ) :
		Sum += arr [ i ]
	mean = Sum / n
	cnt = 0
	for i in range ( n ) :
		newMean = ( Sum - arr [ i ] ) / ( n - 1 )
		if ( newMean == mean ) :
			cnt += 1
	return cnt
arr = [ 1 , 2 , 3 , 4 , 5 ]
n = len ( arr )
print ( countElements ( arr , n ) )