FunctionRacerProblemsRace

Number of Good Pairs

EasyHash mapsPython, JavaScript, TypeScript, Java, C++

A pair of positions (i, j) in the list nums with i < j is good if nums[i] == nums[j]. Return how many good pairs there are.

Example 1

nums [1,2,3,1,1,3]
returns 4

Pairs (0,3), (0,4), (3,4), (2,5): 4.

Example 2

nums [1,2,3]
returns 0

No equal values.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Hash maps problems