Find top-k lottery winners by spending
Company: Amazon
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Technical Screen
Quick Answer: This question evaluates skills in selection and ordering of numeric-keyed records, covering concepts such as order statistics, deterministic tie-breaking, and time and space complexity analysis.
Constraints
- Inputs are Python literals matching the function signature.
- Return a deterministic exact-match value.
Examples
Input: ([('A',10),('B',5),('C',10),('D',1)], 2)
Expected Output: ['A', 'C']
Explanation: Prompt example with deterministic tie-break.
Input: ([('u2',3),('u1',3)], 5)
Expected Output: ['u1', 'u2']
Explanation: k exceeds participant count.
Input: ([], 3)
Expected Output: []
Explanation: No participants.
Hints
- Choose a representation that makes the requested operation direct.
- Handle empty inputs and boundary cases first.