The Online Elite
A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.
- Domain
- Python
- Difficulty
- medium
- Seniority
- L4
Problem
Given merchants (list of dicts with merchant_id and name), payments (list of dicts with merchant_id, amount, mode), and integer top_n, filter payments to mode = 'online'. Per merchant_id, sum amount. Rank merchants by that sum descending. Take the top_n merchants. Return the average of all online payment amounts belonging to those top-n merchants as a single float. If there are no qualifying online payments, return 0.0.
Summary
The top performers are hiding in the data.
Practice This Problem
Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.