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 c7f0398 commit 6407765Copy full SHA for 6407765
Easy/Number of Good Pairs.java
@@ -1,11 +1,11 @@
1
class Solution {
2
- public int numIdenticalPairs(int[] nums) {
3
- Map<Integer, Integer> map = new HashMap<>();
4
- int count = 0;
5
- for (int num : nums) {
6
- count += map.getOrDefault(num, 0);
7
- map.put(num, map.getOrDefault(num, 0) + 1);
+ public int numIdenticalPairs(int[] nums) {
+ Map<Integer, Integer> map = new HashMap<>();
+ int count = 0;
+ for (int num : nums) {
+ count += map.getOrDefault(num, 0);
+ map.put(num, map.getOrDefault(num, 0) + 1);
8
+ }
9
+ return count;
10
}
- return count;
- }
11
0 commit comments