刷题日记LeetCode1512.好数对的数目On this page1512.好数对的数目caution原题链接:https://leetcode.cn/problems/number-of-good-pairs/思路由题意,只需要找到 nums[i] == nums[j] 的个数即可。代码class Solution {public: int numIdenticalPairs(vector<int>& nums) { int m[105], ans = 0; memset(m, 0, sizeof(m)); for (int i = 0 ;i < nums.size(); i++) { ans += m[nums[i]]; m[nums[i]]++; } return ans; }};