EASYasked at 1 company

Relative Ranks

A easy-tier problem at 73% community acceptance, tagged with Array, Sorting, Heap (Priority Queue). Reported in interviews at Electronic Arts and 0 others.

Founder's read

Relative Ranks is an easy problem that asks you to rank scores and return their medal positions. It shows up in Electronic Arts interviews and has a 73% acceptance rate, which is deceptively high. The trick isn't the ranking itself, most people nail that. The trap is managing the index-to-rank mapping cleanly without tangling yourself in nested loops or index confusion. You'll sort, assign medals, then map back to original positions. If you haven't drilled this exact pattern before and hit it live, StealthCoder surfaces the working solution invisibly during your assessment.

Companies asking
1
Difficulty
EASY
Acceptance
73%

Companies that ask "Relative Ranks"

If this hits your live OA

Relative Ranks 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. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE.

Get StealthCoder
What this means

The problem feels straightforward until you realize you need to preserve original indices while sorting. Most candidates sort the array directly and lose track of which score belonged where. The correct approach: create pairs of (score, original_index), sort by score descending, assign medal strings ('Gold', 'Silver', 'Bronze', or the rank number), then reconstruct the result in original order. The key insight is that Heap (Priority Queue) can elegantly handle this with a max-heap, avoiding the need to manually track indices. Common misstep: sorting in-place and then trying to backtrack. StealthCoder is your insurance if the index mapping logic breaks during the live assessment.

Pattern tags

The honest play

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

Relative Ranks 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. Made by a working Amazon engineer who got tired of watching qualified friends bomb OAs they'd solve cold in an IDE. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Relative Ranks interview FAQ

Is Relative Ranks actually easy or is the acceptance rate misleading?+

It's genuinely easy algorithmically. The 73% rate reflects that most candidates know sorting. The gotcha is sloppy index handling, which wastes time and introduces bugs. Once you see the (score, index) pairing pattern, it clicks fast.

Why is Heap listed as a topic if sorting works?+

Sorting is the straightforward path. A max-heap is an alternative that avoids pre-sorting and can feel more elegant. Both are O(n log n). Expect interviewers to ask which you prefer and why.

What's the most common mistake candidates make?+

Sorting the original array in-place, losing the mapping between scores and their original positions. Then they scramble to fix it. Store pairs of (score, index) first, sort those, then build your answer array using the preserved indices.

Does Electronic Arts ask this differently or add constraints?+

No data on variation. Treat it as stated. The company has asked it, so if it appears in your OA, it's likely the standard version with straightforward constraints.

How does this relate to the Array and Sorting topics?+

It's a pure application of sorting with index tracking. It teaches you to think about auxiliary data structures (pairs or heaps) when sorting disrupts information you need later. That pattern shows up in harder array problems.

Want the actual problem statement? View "Relative Ranks" 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.