Problem of the Day
A Fresh Challenge, Every Day
One new problem every day — try to solve it yourself before checking the solution.
Easy
Count Good Pairs
Given an array of integers nums, a pair (i, j) is called a good pair if nums[i] == nums[j] and i < j. Return the number of good pairs.
-
Input: An array of integers
nums. -
Constraints:
1 <= nums.length <= 1001 <= nums[i] <= 100
-
Output: An integer representing the total count of good pairs.
-
Example: Input:
nums = [1,2,3,1,1,3]Output:4Explanation: The good pairs are(0,3),(0,4),(3,4),(2,5).nums[0] == nums[3] (1 == 1) nums[0] == nums[4] (1 == 1) nums[3] == nums[4] (1 == 1) nums[2] == nums[5] (3 == 3)
