File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change
1
+ class Solution {
2
+ public int numIdenticalPairs (int [] nums ) {
3
+ int numGoodPairs = 0 ;
4
+
5
+ for (int i = 0 ; i < nums .length ; i ++) {
6
+ for (int j = 0 ; j < nums .length ; j ++) {
7
+ if (i == j ) continue ; // cannot check against itself
8
+ if (nums [i ] == nums [j ] && i < j ) numGoodPairs ++;
9
+ }
10
+ }
11
+
12
+ return numGoodPairs ;
13
+ }
14
+ }
Original file line number Diff line number Diff line change @@ -140,6 +140,7 @@ Check out ---> [Sample PR](https://github.com/codedecks-in/LeetCode-Solutions/pu
140
140
| 283 | [ Move-Zeroes] ( https://leetcode.com/problems/move-zeroes/ ) | [ C++] ( ./C++/Move-Zeroes.cpp ) | O(N) | O(1) | Easy | Array |
141
141
| 27 | [ Remove-Element] ( https://leetcode.com/problems/remove-element/ ) | [ C++] ( ./C++/remove-element.cpp ) | O(N) | O(1) | Easy | Array |
142
142
| 36 | [ Valid Sudoku] ( https://leetcode.com/problems/valid-sudoku/ ) | [ Java] ( ./Java/valid-sudoku.java ) | O(N^2) | O(N) | Medium | Array, 2D Matrix |
143
+ | 1512 | [ Number of Good Pairs] ( https://leetcode.com/problems/number-of-good-pairs/ ) | [ Java] ( ./Java/Number-of-Good-Pairs.java ) | O(N^2) | O(1) | Easy | Array |
143
144
<br />
144
145
<div align =" right " >
145
146
<b><a href="#algorithms">⬆️ Back to Top</a></b>
You can’t perform that action at this time.
0 commit comments