1512.cpp (212B)
1 class Solution { 2 public: 3 int numIdenticalPairs(const vector<int> &nums) { 4 int count[101] = {0}, res = 0; 5 for (const int n : nums) 6 res += count[n]++; 7 return res; 8 } 9 };