Tap here to switch tabs
Problem
Submissions

Problem: Number of Good Pairs

Number of Good Pairs asks you to count index pairs in an integer array whose values match, counting each pair only when the first index comes before the second.

Statement

Given an array of integers nums, return the total count of good pairs.

A pair (i, j) is considered good if nums[i] == nums[j] and i << j.

Constraints:

  • 1≤1 \leq nums.length ≤102\leq 10^2

  • 1≤1 \leq nums[i] ≤102\leq 10^2

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Number of Good Pairs

Number of Good Pairs asks you to count index pairs in an integer array whose values match, counting each pair only when the first index comes before the second.

Statement

Given an array of integers nums, return the total count of good pairs.

A pair (i, j) is considered good if nums[i] == nums[j] and i << j.

Constraints:

  • 1≤1 \leq nums.length ≤102\leq 10^2

  • 1≤1 \leq nums[i] ≤102\leq 10^2