← Questions

Top k values per key in a MapReduce job

0
DatabricksCodingLast asked Oct 2026

Write the reduce side of a MapReduce job. The mapper passes each (key, value) pair through unchanged and the shuffle groups pairs by key. For every key, output its k largest values (fewer if the key has fewer than k; duplicate values count separately). Keep only k values per key in memory with a bounded min-heap, and be ready to discuss what changes when one key's values don't fit on a single reducer.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding