Number of Good Pairs

July 27, 2020

Number of Good Pairs

class Solution {
    public int numIdenticalPairs(int[] nums) {
        int result = 0;
        for(int i = 0; i< nums.length; i++){
           for(int j = i+1; j < nums.length; j++){
               if(nums[i] == nums[j]){
                   result++;
               }
           }
        }
        return result;
    }
}

Number of Good Pairs


Written by @KimHyoJin Tech Blog