We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d0fe9e4 commit bdbf0baCopy full SHA for bdbf0ba
scripts/algorithms/N/Number of Good Pairs/Number of Good Pairs.cpp
@@ -1,16 +1,17 @@
1
+// Runtime: 8 ms (Top 7.86%) | Memory: 7.2 MB (Top 60.31%)
2
class Solution {
3
public:
- int numIdenticalPairs(vector<int>& nums) {
4
+ int numIdenticalPairs(vector<int>& nums) {
5
- int cnt = 0;
6
- for(int i=0 ; i<nums.size() ; i++){
7
- for(int j=i+1 ; j<nums.size() ; j++){
8
- if(nums[i] == nums[j]){
9
- cnt++;
10
- }
11
12
+ int cnt = 0;
+ for(int i=0 ; i<nums.size() ; i++){
+ for(int j=i+1 ; j<nums.size() ; j++){
+ if(nums[i] == nums[j]){
+ cnt++;
+ }
13
14
- return cnt;
15
+ return cnt;
16
17
};
0 commit comments