반응형
https://leetcode.com/problems/number-of-good-pairs/
class Solution {
public:
int numIdenticalPairs(vector<int>& nums) {
int ans = 0;
for(int i = 0;i<nums.size();i++)
for(int j = i+1;j<nums.size();j++)
if(nums[i] == nums[j])
ans++;
return ans;
}
};
반응형
'IT > 알고리즘' 카테고리의 다른 글
33] Leetcode 1304. Find N Unique Integers Sum up to Zero (0) | 2020.07.15 |
---|---|
32] Leetcode 807. Max Increase to Keep City Skyline (0) | 2020.07.12 |
30★★] Leetcode 1010. Pairs of Songs With Total Durations Divisible by 60 (0) | 2020.07.10 |
29★] Leetcode 1013. Partition Array Into Three Parts With Equal Sum (0) | 2020.07.07 |
28] Leetcode 1021. Remove Outermost Parentheses (0) | 2020.07.06 |
댓글