Loop to find the minimum operations required such that frequency of every character is equal
for i in range ( 1 , 27 ) : NEW_LINE INDENT if ( n % i == 0 ) : NEW_LINE INDENT x = n // i NEW_LINE y = 0 NEW_LINE for j in range ( i ) : NEW_LINE INDENT y += min ( freq [ j ] , x ) NEW_LINE DEDENT answer = min ( answer , n - y ) NEW_LINE DEDENT DEDENT return answer NEW_LINE