unique-number-of-occurrences 1.0.0
Unique Number of Occurrences
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1#include <bits/stdc++.h>
2
3using namespace std;
4
6{
7public:
8 bool uniqueOccurrences(vector<int>& arr)
9 {
10 unordered_map<int, int> occurrences; // key: element from array; value: number of occurrences
11 for (int el: arr)
12 occurrences[el]++;
13
14 set<int> unique_occurrences;
15 for (pair<int, int> pairs: occurrences)
16 {
17 int el = pairs.second;
18 if (unique_occurrences.find(el) != unique_occurrences.end())
19 return false;
20 else
21 unique_occurrences.insert(el);
22 }
23 return true;
24 }
25};
26
27int main()
28{
29
30 return 0;
31}
bool uniqueOccurrences(vector< int > &arr)
Definition main.cpp:8
int main()
Definition main.cpp:27