MCPcopy Create free account
hub / github.com/codedecks-in/LeetCode-Solutions / numIdenticalPairs

Method numIdenticalPairs

Java/Number-of-Good-Pairs.java:2–13  ·  view source on GitHub ↗
(int[] nums)

Source from the content-addressed store, hash-verified

1class 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected