Top-K Largest Elements (Retain / Rank Stores)

Asked at Microsoft · Coding Questions · Difficulty: Easy · Last asked May 15, 2026

Selecting the best few items from a collection is a building block of ranking systems. Implement two small selection functions: one that keeps the K largest numbers of a list while preserving their order, and one that ranks business candidates by a composite key.

Loading the problem…