Skip to content

Commit b80d20c

Browse files
committedJun 8, 2023
leetcode_1512
1 parent 28127ef commit b80d20c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎1512_Number_of_Good_Pairs.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public:
3+
int numIdenticalPairs(vector<int>& nums) {
4+
int ret{};
5+
vector<int> memorization(101, 0);
6+
for(size_t i{}; i<nums.size(); i++){
7+
ret+=memorization[nums[i]];
8+
memorization[nums[i]]++;
9+
}
10+
return ret;
11+
}
12+
};

0 commit comments

Comments
 (0)
Please sign in to comment.