frequency array
#include <bits/stdc++.h>
using namespace std;
int m,n,i,j;
void countfreq(int arr[1000005],int m){
vector<bool> visited (m,false);
for(i=0;i<m;i++){
if(visited[i] == true){
continue;
}
int count = 1;
for(j=i+1;j<m;j++){
if(arr[i] == arr[j]){
visited[j] = true;
count++;
}
}
cout << count << endl;
}
}
int main (){
int m,n;
cin >> m >> n;
int arr[m];
for(i=0;i<m;i++){
cin >> arr[i];
}
countfreq(arr,m);
return 0;
}
Comments
Post a Comment