[InterviewBit] Occurence of Each Number

Occurence of Each Number

  • Time :
  • Space :
1
2
3
4
5
6
7
vector<int> Solution::findOccurences(vector<int> &A) {
map<int, int> mp;
for(auto a : A) mp[a]++;
vector<int> res;
for(auto& [_,v] : mp) res.push_back(v);
return res;
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2022/11/18/PS/interviewbit/occurence-of-each-number/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.