Number of Good Pairs Problem
Number of Good Pairs Problem — ExecCode Easy DSA Practice
Solve the Number of Good Pairs problem on ExecCode. Free online easy DSA practice in Hashing. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given an array of integers nums, return the number of good pairs . Your task is to a pair (i, j) is called good if nums[i] == nums[j] and i < j. Return the required answer exactly as shown in the examples.
Examples
Input {"nums": [1, 2, 3, 1, 1, 3]}; Output 4. Input {"nums": [1, 1, 1]}; Output 3. Input {"nums": [1]}; Output 0
Constraints
1 <= nums.length <= 100 1 <= nums[i] <= 100
Practice Number of Good Pairs free on ExecCode. Browse DSA problems, topic map, and placement guides.