Assign Gold, Silver and Bronze Labels to Code Jam Scores

Last updated: November 29, 2026

Quick Overview

Given distinct contest scores in arrival order, return a label for each: the top three get "Gold Medal", "Silver Medal" and "Bronze Medal", and everyone else gets their placement number as a string.

Google
Coding & Algorithms
Software Engineer
Google
November 29, 2026
Software Engineer
Online Assessment
Coding & Algorithms
Easy

0

0

0 solved


Given distinct contest scores in arrival order, return a label for each: the top three get "Gold Medal", "Silver Medal" and "Bronze Medal", and everyone else gets their placement number as a string.

A warm-up in the style of Google online assessments, themed on a Code Jam style scoreboard. It checks that a candidate can rank while preserving original positions, either by sorting indices or by draining a max-heap.

What the Interviewer Expects
  • Keeps original indices while ranking
  • Uses a heap or sort keyed by score
  • Maps the first three ranks to medal strings
  • Returns results aligned to input order
  • States O(n log n) time
Key Topics to Cover
Max-Heap
Sorting
Ranking
Arrays
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • What if scores can tie (dense versus standard ranking)?
  • What if scores update live?
  • How would you return only the top 10 efficiently?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements
  • Input: list of distinct integer scores; index i is contestant i.
  • Output: list of strings of the same length, where out[i] is contestant i's label.
  • Rank 1 is the highest score....
High-Level Design

We need each contestant's rank but must report it at their original position. Push (-score, index) into a heap and pop in order: the first pop is rank 1, the second rank 2, and so on. Write the labe...


Submit Your Answer
Markdown supported