My issue
help
My code
def min_operations_to_equal_elements(A):
unique_elements = set(A) # Find unique elements in the array
return len(A) - len(unique_elements)
A = list(map(int, input().split()))
# Calculate and print the minimum number of operations
print(min_operations_to_equal_elements(A))
Learning course: Arrays, Strings & Sorting
Problem Link: Equal Elements Practice Problem in - CodeChef
@aryajui
here , plzz refer my c++ code for better understanding of the logic
#include <iostream>
#include<algorithm>
using namespace std;
int main() {
// your code goes here
int t,i;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n];
for(i=0;i<n;i++)
{
cin>>a[i];
}
int count=1;
sort(a,a+n);
int ans=0;
for(i=1;i<n;i++){
if(a[i]==a[i-1])
{
count++;
}
else
{
ans=max(ans,count);
count=1;
}
}
ans=max(ans,count);
cout<<n-ans<<endl;
}
return 0;
}
@aryajui
Refer This Code in Python
My Solution
# cook your dish here
for i in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
c={}
for i in l:
if i not in c:
c[i]=1
else:
c[i]+=1
lar=max(c.values())
print(n-lar)