EASYasked at 1 company

Find the Number of Good Pairs I

A easy-tier problem at 86% community acceptance, tagged with Array, Hash Table. Reported in interviews at Airbus SE and 0 others.

Founder's read

This one's asking you to count pairs of indices (i, j) where i < j and nums[i] == nums[j]. It looks deceptively simple because it is, but speed matters. At 85% acceptance, most candidates nail the logic. The trap is writing inefficient code when you could scan in one pass with a hash table. Airbus SE asks this, and they're testing whether you jump straight to the obvious O(n²) nested loop or catch the O(n) pattern. If you blank on the optimization during your live OA, StealthCoder surfaces the hash table approach in seconds, invisible to the proctor.

Companies asking
1
Difficulty
EASY
Acceptance
86%

Companies that ask "Find the Number of Good Pairs I"

If this hits your live OA

Find the Number of Good Pairs I is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share.

Get StealthCoder
What this means

The naive path is a nested loop: for each element, count how many times it appears after it. Works, but it's slow. The real move is counting occurrences as you iterate left to right. When you see a number you've seen before, add its count to your result, then increment its count in a hash table. Each number contributes multiple pairs: if 5 appears three times, it produces 3 pairs (indices 0-1, 0-2, 1-2). This Array and Hash Table combo cuts your complexity from quadratic to linear. The gap between 'works' and 'optimal' is where interviews live. StealthCoder is the hedge if you freeze on optimization during screen share and need a working solution fast.

Pattern tags

The honest play

You know the problem. Make sure you actually pass it.

Find the Number of Good Pairs I recycles across companies for a reason. It's easy-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an engineer at a top-10 tech company who can solve these problems cold but didn't want to trust himself in a 90-minute screen share. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Find the Number of Good Pairs I interview FAQ

Is this still asked at FAANG-tier companies?+

It's reported from Airbus SE. At 85% acceptance, it's not a high-frequency interview problem anymore, but it shows up in screening rounds. It's easy enough that missing the hash table optimization looks careless to experienced interviewers.

What's the trick I'm missing if I write nested loops?+

Nested loops work, but they're O(n²). The pattern is: hash table counts as you iterate once. Each time you see a number, add its current count to your answer (those are new pairs), then increment the count. Linear time, constant space overhead.

Does this require any special data structure knowledge?+

Just a hash table (or dictionary/map in your language). No trees, no stacks, no advanced structures. Array and Hash Table are the only topics. If you know how to count frequencies in one pass, you've got it.

How does this problem relate to hash tables in interviews?+

It's a canonical 'frequency counting + transformation' problem. Hash tables are tested on how fast you recognize that counting solves the problem. Once you see it, it takes two minutes to code. The interview is testing pattern recognition, not implementation.

Will I see variations of this in my OA?+

Possibly. Variations ask for bad pairs, pairs with specific differences, or pairs meeting other conditions. The core hash table insight (one pass, count as you go) generalizes. Understanding this version gives you the template.

Want the actual problem statement? View "Find the Number of Good Pairs I" on LeetCode →

Frequency and company-tag data sourced from public community-maintained interview-report repos. Problem, description, and trademark © LeetCode. StealthCoder is not affiliated with LeetCode.