leetcodeSolution to some Leetcode problems written in C++ |
git clone git://git.dimitrijedobrota.com/leetcode.git |
Log | Files | Refs | README | LICENSE |
1207.cpp (443B)
0 class Solution {
1 public:
2 bool uniqueOccurrences(const vector<int> &arr) {
3 static int count[2001], seen[1001];
4 memset(count, 0x00, sizeof(count));
5 memset(seen, 0x00, sizeof(seen));
6 for (const int n : arr)
7 count[n + 1000]++;
8 for (const int n : count) {
9 if (!n) continue;
10 if (seen[n]) return false;
11 seen[n] = 1;
12 }
13 return true;
14 }
15 };