Untitled
unknown
c_cpp
3 years ago
319 B
8
Indexable
void frequencyCount(vector<int>& arr,int n, int p)
{
// code here
unordered_map<int,int> map;
for (int i=0; i<n; i++) map[arr[i]]++;
for (int i=1; i<=p; i++){
if (map.count(i)>0) cout << map[i] << " ";
else cout << 0 << " ";
}
}Editor is loading...